方式一:继承 spring-boot-starter-parent项目
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
</parent>
方式二:导入spring-boot-dependencies项目依赖
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.5.12.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
因为一般我们的项目中,都有项目自己的parent项目。所以【方式一】会存在冲突,实际场景下,推荐使用【方式二】。 需要注意的是,在子项目的dependencies中,不需要(也不能)再次添加对spring-boot-dependencies的声明了,否则子项目将无法编译通过。
为什么呢?因为spring-boot-dependencies没有对应的jar包,它只是一个pom配置,里面定义了很多的依赖声明。有了它之后,我们在子项目中使用到的相关依赖,就不需要声明version了。
参考:https://blog.csdn.net/rainbow702/article/details/55046298