官方系统构建:https://docs.spring.io/spring-boot/docs/current/reference/html/using.html#using.build-systems
使用maven构建聚合项目时,一般顶层的项目我们都没有引入parent包括spring-boot-starter-parent,很多时候顶层的项目就是其下子模块的parent,这个时候在子模块pom中是没法引入spring-boot-starter-parent的。这个时候,我们可以在顶层pom中引入spring-boot-dependencies
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
不想使用spring-boot-starter-parent,你依然可以通过使用spring-boot-dependencies的scope=import利用依赖管理的便利。
我们通过分析spring-boot-starter-parent发现它继承了spring-boot-dependencies,同时spring-boot-starter-parent提供了很多官方约定的功能


当构建Spring Boot聚合项目时,如果顶层项目不包含spring-boot-starter-parent,可以引入spring-boot-dependencies来实现依赖管理。通过在顶层pom的dependencyManagement部分添加spring-boot-dependencies,设置scope为import,可以享受与使用spring-boot-starter-parent相同的便利,而无需直接继承它。这样,子模块仍然能受益于Spring Boot的官方约定和依赖版本控制。
2万+

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



