maven的pom文件中<relativePath/>的作用
官方说明: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.
简单总结一下:
· 如果没有指定
· 如果显式地设置为空值(<relativePath/>或<relativePath></relativePath>)则先从本地仓库拉取,然后去远程仓库拉取
由此得出Maven的默认查找顺序是:文件系统 > 本地仓库 > 远程仓库
所以在
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository 直接从远程库拉取 -->
</parent>
中,因为
在
<parent>
<groupId>com.timqiu.gulimall</groupId>
<artifactId>gulimall</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
或
<parent>
<groupId>com.timqiu.gulimall</groupId>
<artifactId>gulimall</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
中,文件系统 > 本地仓库 > 远程仓库
浙公网安备 33010602011771号