我的工作了,和這裏的細節:
首先,有沒有辦法來指定文件包括或排除如果使用內置的裝配描述JAR-與依賴關係。
裝配插件文檔給出樣本jar-with-dependencies descriptor here。
我將該描述符複製並粘貼到名爲exec-jar.xml的項目目錄中的文件中。然後在pom中,我改變了程序集插件以引用該描述符。下面是摘錄:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-3</version>
<configuration>
<descriptors>
<descriptor>exec-jar.xml</descriptor>
</descriptors>
<archive>
<manifest>
<mainClass>com.package.MyMainClass</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
描述的該位結合的組件生命週期的包裝階段,並引用EXEC-jar.xml描述符。做這個包確認了jar是和預定義的描述符一起構建的。
然後,它成爲修改exec-jar.xml來排除與Spring文件衝突的CXF文件的問題。這是我的裝配描述符,它完成了:
<assembly>
<id>jar-with-dependencies</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<unpack>true</unpack>
<unpackOptions>
<excludes>
<exclude>cxf*/META-INF/spring.handlers</exclude>
<exclude>cxf*/META-INF/spring.schemas</exclude>
</excludes>
</unpackOptions>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>${project.build.outputDirectory}</directory>
</fileSet>
</fileSets>
</assembly>
現在,這裏是蹭。如果使用當前發佈的彙編插件2.1版進行此操作,它將在標籤上以「意外」方式失敗。標籤在插件的未發佈版本2.2中受支持。請注意,在我上面的pom文件摘錄中,我指定了maven-assembly-plugin版本2.2-beta-3,這是本文寫作時的最新版本。
這成功地構建了一個可執行的jar,並且Spring擁有了初始化我的應用程序所需的所有處理程序和模式。
同樣的事情發生與「spring.tooling」的文件,但是從他們的名字我猜他們不是在運行時使用。 – 2010-10-12 05:12:08