本文介绍了如何制作“胖罐”一个Maven项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用IntelliJ我刚刚创建了一个新的Maven项目,并将以下内容添加到pom文件中以及以下的Main.java文件
Using IntelliJ I just created a new Maven project and added the following to the pom file http://undertow.io/downloads.html and the following to a Main.java file http://undertow.io/index.html
现在,如果我运行代码一切运行良好,但我如何将其作为一个胖罐,将包含所有依赖项pom文件,我只能通过 java -jar my.jar
运行?就像你可以使用Spring Boot应用程序一样。
Now if I run the code all works well, but how do I make this as a "fat jar" that will contain all the dependencies in the pom file and that I'll be able to run by just java -jar my.jar
? Like you are able to do with a Spring Boot app.
推荐答案
做得很好。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>package.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
这篇关于如何制作“胖罐”一个Maven项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!