在项目的pom.xml文件里添加如下内容:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>sample.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
本文介绍如何在Maven项目中使用maven-shade-plugin插件将项目及其依赖打包成一个可执行的单个Jar文件。通过在pom.xml中配置插件,指定主类,实现项目的便捷部署。
1333

被折叠的 条评论
为什么被折叠?



