2011-03-11 84 views
2

我創建了一個簡單的Maven項目(打包類型 - Jar),它依賴於Spring和My Sql庫(mysql-connector)。當我用$mvn package打包這個項目時,我在成功執行這個命令後得到了一個jar文件。jar-with-dependencies Maven Assembly

我也想在輸出中包括jar文件中所有的依賴,所以我加了一個「罐子與 - 依賴」裝配描述,但作爲文件說:

The `jar-with-dependencies` descriptor builds a JAR archive with the contents of the main project jar along with the unpacked contents of all the project’s runtime dependencies. 

我想包括JAR表單中的依賴項,而不是unpacked的方式。我怎樣才能做到這一點?

回答

4

Java無法從開箱即裝的jar中加載類。您必須使用one-jarmaven plugin等項目對其進行配置。

0

玉萍試圖聚集的罐子,這被稱爲在Maven的術語「建築的聚集型罐子」。您可以在Robert的[1]和Artifact Technical Notes'[2]博客中找到更多信息。 一個討論[3],也可以幫助。

問候

[1] http://rombertw.wordpress.com/2010/05/14/maven-recipe-building-an-aggregate-jar/

[2] http://blog.artifact-software.com/tech/?p=121

[3] http://maven.40175.n5.nabble.com/Aggregate-POM-for-thirdparty-package-dependencies-not-downloaded-td113927.html