0
我想创建一个可执行的jar包含我的外部jar。 我已经阅读下文提到的文章,但对我来说,这个外部JAR我必须使用如下: #MYGROUP# #myArtifact# #VERSION# 系统 $ {} project.basedir/lib目录/#myjar#.jar 由于systemPath,我必须使用范围系统,这就是为什么我的jar不会包含在我的最终可执行jar文件中。 当我尝试运行我的jar时,它会以NoClassDefFoundError结束到我的外部jar。 你能帮我一下,如何将我的外部jar包含到我的最终可运行jar中。maven创建与外部库的脂肪罐
Here is my current plugins:
<!-- compiler plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<!-- Make this jar executable -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>#MYMAINCLASS#</mainClass>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<!-- Copy project dependency , can be used when we have repository.-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Thanks you answer in advance!
http://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven
https://www.mkyong.com/maven/create-a-fat-jar-file-maven-assembly-plugin/