Maven: Running created Jar
This question already has an answer here:
把这个maven程序集插件放到你的pom.xml中:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>de.my.path.MainClass</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
There are multiple options.
maven app assembly plugin
This package all dependent jars and also creates linux/ windows scripts to run your application. See Here for more information on how to use it.
Maven assembly plugin
It creates single executable jar including all dependencies. More here. However i found this problematic with some third party jars(spring) where there are files with same names.
上一篇: Maven和Hibernate项目
下一篇: Maven:运行创建的Jar