如何统一引入spring boot版本

方式一:继承 spring-boot-starter-parent项目spring

<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.5.2.RELEASE</version>
	</parent>

方式二:导入spring-boot-dependencies项目依赖spring-boot

<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的声明了,不然子项目将没法编译经过。.net

为何呢?由于spring-boot-dependencies没有对应的jar包,它只是一个pom配置,里面定义了不少的依赖声明。有了它以后,咱们在子项目中使用到的相关依赖,就不须要声明version了。code

参考:http://www.javashuo.com/article/p-fdlutcww-hs.htmlblog

相关文章
相关标签/搜索