単一の jar としてパッケージ化したい Maven ベースの Spring-WS クライアント プロジェクトがあります。日食では、すべてが適切に実行されます。実行可能 jar としてパッケージ化しようとすると、Spring jar がアプリケーション jar に含まれていないため、ClassNotFound 例外が発生します。
そこで、maven-shade-pluginを追加して、すべての依存関係をアプリケーション jar に含めました。アプリ jar を見ると、含まれているすべての依存関係からのすべてのクラス ファイルが表示されます (すべてのライブラリ jar が展開されています)。
<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>
私の問題は、パッケージ化プロセスで、複数の春の依存関係に、互いにオーバーライドする異なるMETA-INF/spring.schemasファイルがあることです。その結果、最終的な jar には不完全な spring.schemas ファイルがあります。
そのため、実行可能な jar を実行しようとすると、spring.schemas ファイルが不完全であるためファイルが見つからないという Spring エラー メッセージが表示されます (Spring-WS の jar が Spring-core の spring.schemas ファイルをオーバーライドしました)。
私の実行可能 jar の META-INF/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
Spring-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
私は困惑しています。すべてを単一の実行可能 jar としてパッケージ化できるかどうか、またはその方法がわかりません。これがシェード プラグインの設定の問題なのか、不可能なことをしようとしているのかはわかりません。独自の spring.schemas ファイル (他のファイルの連結) を手動で作成する必要があるというのは正しくないように思われます。
私は少し銃を飛ばしたかもしれません。シェード プラグインについてさらに情報を掘り下げていくと、以前は見逃していたAppendingTransformerに気付きました。しかし、私の懸念は、他のどのファイルが同じ問題を抱えているかを知る方法ですか? この特定の春の問題を発見/キャッチしました。同様のことをしている可能性のある他のライブラリについてはわかりません...
任意の提案をいただければ幸いです。