在Maven中,主要有3个插件可以用来打包:
- maven-jar-plugin,默认的打包插件,用来打普通的project JAR包;
- maven-shade-plugin,用来打可执行JAR包,也就是所谓的fat JAR包;
- maven-assembly-plugin,支持自定义的打包结构,也可以定制依赖项等。
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.sonatype.haven.HavenCli</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
</project>
?参考官方文档:http://maven.apache.org/plugins/maven-shade-plugin/examples/executable-jar.html
?
|