【发布时间】:2019-05-05 06:25:56
【问题描述】:
我在源存储库中提交了 jar,我需要将其用作 maven 项目中的依赖项。经过研究,添加项目特定的本地存储库似乎是最干净的方法。请注意,此存储库将特定于此项目,并且与我机器上 .m2 目录下的本地存储库不同。 pom 是战争类型,我在描述下方定义了这样的存储库:
<repositories>
<repository>
<id>project-repo</id>
<name>project-repo</name>
<url>file://${basedir}/WebContent/WEB-INF/lib</url>
</repository>
</repositories>
在 lib 目录中是 jar 的路径,没有其他文件:
com/mycompany/stuff/my-artifact/1.0.0/my-artifact-1.0.0.jar。
这个依赖在同一个pom.xml中:
<dependency>
<groupId>com.mycompany.stuff</groupId>
<artifactId>my-artifact</artifactId>
<version>1.0.0</version>
</dependency>
如果我查看 Effective POM,我会看到在我的用户 settings.xml 中定义的两个存储库下列出了带有正确路径的 project-repo。所以它被列出来了,但它被列在最后。当我执行 mvn clean 包时,它失败并出现错误:无法在 settings.xml 的“repo 名称”中找到工件。它似乎没有检查我在 pom.xml 中指定的存储库。在其他帖子中,我使用这个:How to include local jar files in Maven project 作为参考,maven 文档在这里找到:https://maven.apache.org/guides/mini/guide-multiple-repositories.html 和这里:https://maven.apache.org/guides/introduction/introduction-to-repositories.html。任何想法为什么它似乎只检查 settings.xml 中定义的存储库?
【问题讨论】: