maven项目用assembly打包可执行jar包
Posted 瓜子
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了maven项目用assembly打包可执行jar包相关的知识,希望对你有一定的参考价值。
该方法只可打包非spring项目的可执行jar包,spring项目可参考:http://www.cnblogs.com/guazi/p/6789679.html
1.添加maven插件:
<!-- Maven Assembly Plugin --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.4.1</version> <configuration> <!-- get all project dependencies --> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <!-- MainClass in mainfest make a executable jar --> <archive> <manifest> <mainClass>com.jobscrawler.crawlers.ShhCrawler</mainClass> </manifest> </archive> </configuration> <executions> <execution> <id>make-assembly</id> <!-- bind to the packaging phase --> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin>
2.mvn clean(清理下项目)
3.maven update project
4.命令后执行命令mvn assembly:assembly -Dmaven.test.skip
进入target目录会看到这两个jar包:
jobscrawler-1.0-SNAPSHOT-jar-with-dependencies.jar
jobscrawler-1.0-SNAPSHOT.jar
5.执行 java -jar jobscrawler-1.0-SNAPSHOT-jar-with-dependencies.jar
如果这个不管用,可以参考http://www.cnblogs.com/liqiu/p/3816068.html
http://www.cnblogs.com/liqiu/p/4508848.html
---恢复内容结束---
以上是关于maven项目用assembly打包可执行jar包的主要内容,如果未能解决你的问题,请参考以下文章