1.初试了下springboot,发现dependency都无需指定jar包版本。
spring boot 在定义pom的时候,会引入一个parent:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.4.RELEASE</version>
</parent>
而这个spring boot starter parent 又指定了:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.4.4.RELEASE</version>
<relativePath>../../spring-boot-dependencies</relativePath>
</parent>
spring-boot-dependencies中定义了<dependencyManagement>,
其中定义了一系列的依赖及其版本,
<dependencyManagement>
<dependencies>
<!-- Spring Boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>1.4.4.RELEASE</version>
</dependency>
</dependencies>
</dependencyManagement>
那 dependencyManagement有什么用呢?
我们通过它的元素来管理jar包的版本,让子项目中引用一个依赖而不用显示的列出版本号。Maven会沿着父子层次向上走,直到找到一个拥有dependencyManagement元素的项目,然后它就会使用在这个dependencyManagement元素中指定的版本号
浙公网安备 33010602011771号