gpt4 book ai didi

java - 如何告诉 Maven 在本地哪里搜索父 POM?

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:20:06 24 4
gpt4 key购买 nike

我有许多 Maven 项目 在我的机器上 checkout ,格式如下:

my-project/
pom.xml
my-other-project/
pom.xml

my-other-project声明 my-project 中的 POM 文件将被用作 parent 。问题是 my-project还不在 Maven 存储库中,这是两个独立的项目,因此 Maven 无法在本地搜索找到父 POM。有没有办法告诉 Maven 查看 my-project/在搜索存储库之前查找父 POM?

这是我在运行 mvn package 时遇到的确切错误:

[INFO] Scanning for projects...
Downloading: https://repo.maven.apache.org/maven2/com/mycom/my-project/1.0.0/pom-base-1.0.0.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for com.mycom:my-other-project:1.0.0: Could not find artifact com.mycom:pom-base:pom:1.0.0 in central (https://repo.maven.apache.org/maven2) and 'parent.relativePath' points at wrong local POM @ line 39, column 11

编辑:

可以设置<relativePath>../my-project</relativePath在父声明中,但如果这可以自动发生就好了。

最佳答案

relativePath 如果您不想在 repo 中包含本地项目,则可以使用此方法。这就是此元素的用途,如 reference documentation 中所述:

The relative path of the parent pom.xml file within the check out. If not specified, it defaults to ../pom.xml. Maven looks for the parent POM first in this location on the filesystem, then the local repository, and lastly in the remote repo. relativePath allows you to select a different location, for example when your structure is flat, or deeper without an intermediate parent POM. However, the group ID, artifact ID and version are still required, and must match the file in the location given or it will revert to the repository for the POM. This feature is only for enhancing the development in a local checkout of that project. Set the value to an empty string in case you want to disable the feature and always resolve the parent POM from the repositories.

关于java - 如何告诉 Maven 在本地哪里搜索父 POM?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30693312/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com