[英]How do I create and run an executable jar with maven that has external dependencies?
I have a jar plugin but it's not running because it isn't including the external dependencies in the jar. 我有一个jar插件,但未运行,因为它未在jar中包含外部依赖项。 I can't seem to figure out how to include these dependencies, I seem to be finding a bunch of different solutions that conflict with each other for some reason.
我似乎无法弄清楚如何包含这些依赖关系,我似乎正在发现一堆由于某种原因而相互冲突的不同解决方案。 I ideally would like it to run on systems without the need for any special maven commands.
理想情况下,我希望它可以在不需要任何特殊maven命令的系统上运行。
create maven pom.xml with 用以下命令创建Maven pom.xml
<packaging>jar</packaging>
By default it should not pack into your jar all dependent libraries. 默认情况下,它不应将所有依赖库打包到您的jar中。
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
What you are looking for is to build an über-jar. 您正在寻找的是建造一个über-jar。 The Maven Shade plugin can do that - http://maven.apache.org/plugins/maven-shade-plugin/ .
Maven Shade插件可以做到这一点-http://maven.apache.org/plugins/maven-shade-plugin/ 。 It even allows for renaming of classes.
它甚至允许重命名类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.