了解Maven的 relativePath标签
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
从父级仓库查找依赖版本
MAVEN构建jar包时候查找顺序:relativePath元素中的地址>本地仓库>远程仓库
举例
父模块配置
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
</dependency>
子模块 没有配置 <relativePath/>
如果<dependencies>中依赖没有指定版本,编译时不能获取父<dependencyManagement>中定义的版本。
本文介绍了Maven项目中使用relativePath标签的意义与作用。当构建jar包时,Maven会根据relativePath元素中的地址、本地仓库及远程仓库的顺序来查找依赖版本。文章通过实例说明了如何在父模块配置依赖,并在子模块中继承这些依赖。
4988

被折叠的 条评论
为什么被折叠?



