开发者

How do I create a standalone jar from a maven project?

开发者_Python百科I am trying to create a standalone jar file I don't think that maven package is properly packaging my dependencies into the package. Is there a way to force it to include them?


Alternately you could use the jar-with-dependencies packaging of maven assembly plugin.


You need to use the shade plugin.

By default maven builds and packages the compile output from the current project. The shade plugin allows to you create an 'uber' jar that contains not just your code but all of the dependencies into a single (sometimes quite big) jar.

Optionally allows you to relocate classes in the packaging phase, meaning that your project can have completely private copies of it's dependencies without getting caught in jar hell.


You can find an a basic example on how to use the maven assembly plugin here.

You need only to clone the repository

git clone git://github.com/db80/java-skeleton.git

and run mvn package

cd java-skeleton && mvn package


Please check this answer https://stackoverflow.com/a/35359756/5678086 for creating full pack with all dependencies

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜