您的位置:首页 > 其它

maven 如何让所依赖的jar都被打包在一个jar里面呢

2014-09-22 21:51 405 查看
How creates a single JAR file that includes all of the bytecode from

the project as well as the unpacked bytecode from all of the dependencies.

1. Assembly plugin 插件

配置 Maven Assembly Descriptor。 pom文件内
<project>
[...]
<build>
<plugins>
<plugin>
Maven by Example
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>


Once you’ve added this configuration, you can build the assembly by running the assembly:assembly

goal. In the following screen listing, the assembly:assembly goal is executed after the Maven build

reaches the install lifecycle phase:

$ mvn install assembly:assembly
配置完pom 文件后,运行命令 mvn install assembly:assembly ,

本地仓库找打你的jar 文件,打开后发现依赖的jar包都在里面。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: