maven项目打包jar,含有依赖jar

在pom文件中添加一下插件

1 <plugin>
2                 <artifactId>maven-assembly-plugin</artifactId>
3                 <configuration>
4                     <descriptorRefs>
5                         <descriptorRef>jar-with-dependencies</descriptorRef>
6                     </descriptorRefs>
7                 </configuration>
8             </plugin>

通过以下命令mvn assembly:assembly执行

如果是idea工具,在maven project选项卡下,找到对应的项目,按图所示,双击执行,会生成以-jar-with-dependencies结尾的JAR包. 这个JAR包就包含了项目所依赖的所有JAR的CLASS

原文地址:https://www.cnblogs.com/bbthome/p/9229968.html