如果项目存在多重继承关系,当父pom中使用
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.12.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
在子项目继承父pom时,当使用一些spring boot 已提供版本相关的依赖时,无法使用spring boot中自带的版本。
可以如下使用:
在 properties中定义spring boot 版本
<springframework.boot.version>1.5.12.RELEASE</springframework.boot.version>
在dependencies中添加如下依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>${springframework.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
之后在子项目中继承父pom就可以直接使用spring boot内置的版本依赖了。
还需要注意一点,这种依赖方式相关spring boot的依赖包只能在子项目中直接使用,最好不要在父pom的dependencies中再次申明,否则可能会出现版本冲突(unknow), 因为默认子项目中还是会使用父pom中申明的依赖。