[英]mvn jar file : library include failed
I did mvn package
and ran my file by doing java -jar target\\output.jar
我做了
mvn package
并通过java -jar target\\output.jar
运行我的文件
All the jar libraries specified in the dependency of pom.xml are not included. 不包括在pom.xml的依赖项中指定的所有jar库。 Do advice what's wrong below.
请在下面提出建议。 Thanks!
谢谢!
Below is my pom.xml to allow jar file generation. 下面是我的pom.xml,允许生成jar文件。
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.workspez.psg.letrikEtara.PlanetGroupLetrikEtara</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
Try and compare/complete your declaration with the ones in " Including dependencies in a jar with Maven ", like adding the executions
section. 尝试与“ 使用Maven包含jar中的依赖关系”中的声明进行比较/完成声明,例如添加
executions
部分。
Or, if this is not working, consider the maven shade plugin , whic can achieve a simlar goal. 或者,如果这不起作用,请考虑maven shade插件 ,它可以实现一个类似的目标。
Got it working. 搞定了。 This was missing:
这个缺失了:
<descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs>
To the following should work: 以下应该工作:
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.workspez.psg.letrikEtara.PlanetGroupLetrikEtara</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.