关于这个其实官方文档已经有了相关说明:

​https://docs.spring.io/spring-boot/docs/2.0.4.RELEASE/reference/htmlsingle/#using-boot-maven-without-a-parent​

一般我们的项目都是自己去定义 parent,不会使用 SpringBoot 的,但是由于 Maven 是单继承的,这时候可以使用 ​​<scope>import</scope>​​ :

<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.0.4.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

这样也相当于 parent 中引入了很多依赖,子模块直接引用即可。

欢迎关注公众号

​​​​​

项目不使用 SpringBoot 的 parent pom_Management