[英]How do I create and run an executable jar with maven that has external dependencies?
我有一個jar插件,但未運行,因為它未在jar中包含外部依賴項。 我似乎無法弄清楚如何包含這些依賴關系,我似乎正在發現一堆由於某種原因而相互沖突的不同解決方案。 理想情況下,我希望它可以在不需要任何特殊maven命令的系統上運行。
用以下命令創建Maven pom.xml
<packaging>jar</packaging>
默認情況下,它不應將所有依賴庫打包到您的jar中。
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
您正在尋找的是建造一個über-jar。 Maven Shade插件可以做到這一點-http://maven.apache.org/plugins/maven-shade-plugin/ 。 它甚至允許重命名類。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.