Ho un progetto client Spring-WS basato su Maven che voglio impacchettare come un singolo jar. In Eclipse, tutto funziona correttamente. Quando provo a confezionarlo come un jar eseguibile, ottengo eccezioni ClassNotFound poiché i jar di Spring non sono inclusi nel jar dell'applicazione.Come creare un jar eseguibile basato a molla con maven?
Così ho aggiunto lo maven-shade-plugin per includere tutte le mie dipendenze nel mio jar dell'applicazione. Quando guardo il mio jar di app, vedo tutti i file di classe da tutte le dipendenze incluse (tutti i jar della libreria sono esplosi).
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.cws.cs.Client</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Il mio problema è che nel processo di confezionamento, i miei più dipendenze primaverili hanno diversi META-INF/spring.schemas file che sostituiscono l'un l'altro. Di conseguenza, il mio jar finale ha un file spring.schemas incompleto.
Così quando provo a eseguire il mio jar eseguibile, ricevo i messaggi di errore di Spring che i file non possono essere trovati poiché il file spring.schemas è incompleto (il vaso Spring-WS ha scavalcato il file spring.schemas di Spring-core).
miei META-INF del jar eseguibile/spring.schemas:
http\://www.springframework.org/schema/web-services/web-services-1.5.xsd=/org/springframework/ws/config/web-services-1.5.xsd
http\://www.springframework.org/schema/web-services/web-services-2.0.xsd=/org/springframework/ws/config/web-services-2.0.xsd
http\://www.springframework.org/schema/web-services/web-services.xsd=/org/springframework/ws/config/web-services-2.0.xsd
Invece di Primavera-beans.jar META-INF/spring.schemas:
http\://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd
http\://www.springframework.org/schema/beans/spring-beans-2.5.xsd=org/springframework/beans/factory/xml/spring-beans-2.5.xsd
http\://www.springframework.org/schema/beans/spring-beans-3.0.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd
http\://www.springframework.org/schema/beans/spring-beans-3.1.xsd=org/springframework/beans/factory/xml/spring-beans-3.1.xsd
http\://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-3.1.xsd
http\://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd
http\://www.springframework.org/schema/tool/spring-tool-2.5.xsd=org/springframework/beans/factory/xml/spring-tool-2.5.xsd
http\://www.springframework.org/schema/tool/spring-tool-3.0.xsd=org/springframework/beans/factory/xml/spring-tool-3.0.xsd
http\://www.springframework.org/schema/tool/spring-tool-3.1.xsd=org/springframework/beans/factory/xml/spring-tool-3.1.xsd
http\://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-3.1.xsd
http\://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd
http\://www.springframework.org/schema/util/spring-util-2.5.xsd=org/springframework/beans/factory/xml/spring-util-2.5.xsd
http\://www.springframework.org/schema/util/spring-util-3.0.xsd=org/springframework/beans/factory/xml/spring-util-3.0.xsd
http\://www.springframework.org/schema/util/spring-util-3.1.xsd=org/springframework/beans/factory/xml/spring-util-3.1.xsd
http\://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-3.1.xsd
stumped. Non sono sicuro se/come posso impacchettare tutto come un singolo jar eseguibile. Non so se questo è un problema di configurazione di ombreggiamento del plugin, o se sto cercando di fare qualcosa di impossibile. Non sembrerebbe corretto che dovrei creare manualmente il mio file spring.schemas (una concatenazione degli altri).
Forse ho saltato un po 'la pistola. Nel scavare più informazioni sul plugin per l'ombra, ho notato lo AppendingTransformer che avevo precedentemente perso. Tuttavia, la mia preoccupazione è come sapere quali altri file hanno gli stessi problemi? Ho scoperto/preso questo particolare problema di primavera. Non ho idea di altre librerie che potrebbero fare qualcosa di simile ...
Qualsiasi suggerimento sarebbe apprezzato.
approccio alternativo che funziona alla grande è quello di mettere vasi di primavera nella cartella lib separata, e aggiungere questa cartella 'lib' nel percorso di classe in manifesta - vedere André Aronsen di rispondi a http://stackoverflow.com/a/4323501/241986 –