我有一个需要部署的项目,我想获取它的 jar 以及所有依赖的 jar。
最简单的方法是什么?
最佳答案
使用maven依赖插件:
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>
以上内容摘自 mojo 文档,描述了如何 Copy project dependencies
对于新 Maven 用户来说另一个有用的链接是 the list of maven plugins .
关于java - Maven - 如何获取所有依赖的 Artifact ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23815817/