Maven pom中的parent.relativePath的作用(官网说明)

Maven pom中的parent.relativePath的作用(官网说明),第1张

Maven pom中的parent.relativePath的作用(官网说明)

在开发项目过程中遇到一个问题,引入parent没有加relativePath会报红,

解决的办法是加

项目结构说明:项目未放置在parent项目目录下。parent项目和子项目在目录上是平级的:

在网上看到很多人问这个问题,回答都是一致的copy.

现在从官网上找答案 :

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.
Default value is: ../pom.xml.

1.不加:默认是 ../pom.xml

2.也可以在此指定

指定后将在文件系统从指定位置查找,然后是本地仓库,最后是远程仓库

(优先级 指定位置 > 本地仓库 > 远程仓库)

3.加上标签关闭这个特性(feature) ,将永远从repositories解析读取parent  POM

到此完成.(英文水平有限,如有问题请指正,谢谢!)

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5605691.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存