我有 Maven 项目,它依赖于存储库和其他东西。我想“导出”其所有依赖项的源代码,以便我可以在 IDE 中成功打开它,而无需在计算机上运行 Maven。
当将项目打包成war文件时,它会打包所有依赖项。
所以我想将所有依赖项和我的源代码聚集在一个地方,可以使用 IDE(Eclipse 或 IDEA)打开所有检测到的库?
最佳答案
尝试使用 maven-dependency-plugin 目标 copy-dependencies
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<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>
附注。
您是否了解 Maven 和 IDE 集成(对于 Eclipse p.e.)? Maven 可以为特定 IDE 生成项目,并将所有依赖 jar 作为变量包含(指向本地存储库中的这些 jar),因此无需使用复制依赖项到子文件夹。
关于maven-2 - Maven : how to export project with sources and dependencies,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1751551/