• 理解maven的parent标签里面的relativePath


    经常看到用Spring Initializr建立spring boot项目,生成的pom.xml包含如下parent:

        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.6.2</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>

    也会看到一些maven module项目包含下面relativePath形式:

        <parent>
            <artifactId>admin</artifactId>
            <groupId>org.example</groupId>
            <version>1.0-SNAPSHOT</version>
            <relativePath>../pom.xml</relativePath>
        </parent>

    也有不写relativePath的,直接如下:

        <parent>
            <artifactId>admin</artifactId>
            <groupId>org.example</groupId>
            <version>1.0-SNAPSHOT</version>
        </parent>

    参考官方文档发现,relativePath是与从哪里继承相关联的,默认③什么都不写等同于②,像①那种是不依赖本地parent pom,直接从reposity拉取,

    Maven looks for the parent pom first in the reactor of currently building projects, then in this location on the filesystem, then the local repository, and lastly in the remote repo.

    寻找parent pom优先级:本地项目>文件系统>本地库>远程库,而springboot默认都是直接从远程库拉取的。

    参考文档:

    Understanding Maven’s “relativePath” Tag for a Parent POM:https://www.baeldung.com/maven-relativepath

  • 相关阅读:
    Python-TXT文本操作
    Appium-处理系统弹窗
    Appium-服务关键字
    App Inspector-iOS真机功能详解
    Appium+Python3+iOS真机环境搭建
    Appium-超过60s的应用场景如何处理
    python-入门的第一个爬虫例子
    Mysql(五) JDBC
    Mysql(四)正则表达式
    Mysql(三)约束
  • 原文地址:https://www.cnblogs.com/feibazhf/p/15848042.html
Copyright © 2020-2023  润新知