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

一、发现问题

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

二、最终解决方案

解决的办法是加<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.不加<relativePath>:默认是<relativePath> ../pom.xml</relativePath>

2.<relativePath>也可以在此指定<relativePath/>

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

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

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

----------------------------------------------------------

到此完成。

(英文水平有限,如有问题请指正,谢谢!)

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值