maven pom relativePath属性的作用

maven pom relativePath属性的作用

文章目录

一、relativePath出现的地方

搭建maven项目,子模块指定父模块试,经常会在parent下面出现relativePath类似下面:

复制代码
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.2.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

二、relativePath默认值

默认我们不用写<relativePath>,那默认值就是 ../pom.xml,会从本地路径中获取parent的pom。

在开发多模块的时候,经常这么写:

复制代码
    <parent>
        <groupId>cn.hefrankeleyn</groupId>
        <artifactId>hefrpc</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>

三、<relativePath/>

这样写,也就是说我指定了relativePath,但值是空的,设定一个空值将始终从仓库中获取,不从本地路径获取.

很常见的场景就是使用springboot的时候:

复制代码
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.2.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

四、<relativePath>一个pom路径<relativePath/>

指定一个本地的路径,从本地路径获取parent的pom

相关推荐
Drifter_yh4 小时前
【黑马点评】Redisson 分布式锁核心原理剖析
java·数据库·redis·分布式·spring·缓存
莫寒清5 小时前
Spring MVC:@RequestParam 注解详解
java·spring·mvc
没有医保李先生6 小时前
字节对齐的总结
java·开发语言
甲枫叶7 小时前
【claude】Claude Code正式引入Git Worktree原生支持:Agent全面实现并行独立工作
java·人工智能·git·python·ai编程
六件套是我8 小时前
无法访问org.springframeword.beans.factory.annotation.Value
java·开发语言·spring boot
LYS_06188 小时前
C++学习(5)(函数 指针 引用)
java·c++·算法
forestsea8 小时前
Spring Cloud Alibaba 2025.1.0.0 正式发布:拥抱 Spring Boot 4.0 与 Java 21+ 的新时代
java·spring boot·后端
IT枫斗者8 小时前
IntelliJ IDEA 2025.3史诗级更新:统一发行版+Spring Boot 4支持,这更新太香了!
java·开发语言·前端·javascript·spring boot·后端·intellij-idea
forestsea8 小时前
Spring Boot 4.0 + JDK 25 + GraalVM:下一代云原生Java应用架构
java·spring boot·云原生