使用 IntelliJ 我刚刚创建了一个新的 Maven 项目并将以下内容添加到 pom 文件中http://undertow.io/downloads.html http://undertow.io/downloads.html以及 Main.java 文件中的以下内容http://undertow.io/index.html http://undertow.io/index.html
现在,如果我运行代码一切正常,但我如何将其制作为一个“胖罐子”,它将包含 pom 文件中的所有依赖项,并且我将能够通过以下方式运行java -jar my.jar
?就像您可以使用 Spring Boot 应用程序一样。
Maven 阴影插件 https://maven.apache.org/plugins/maven-shade-plugin/examples/executable-jar.html这一点做得很好。
<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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)