我有一个使用 Spring Boot 1.3.8 的多模块项目。目前我想更新到 1.4.1,但目前很痛苦,因为几乎没有其他重大升级,如 querydsl、thyemeleaf、hibernate。
所以我找到了可以将 Hibernate 5 与 Spring Boot 1.3.8 一起使用的信息,并且只需覆盖属性中的 hibernate 版本号即可。 (示例:enter link description here)
我在 Parent Pom 中做了:
<properties>
<hibernate.version>5.0.11.Final</hibernate.version>
...
</properties>
这是在依赖管理下声明 Spring Boot 依赖的同一个 pom:
<dependencyManagement>
<dependencies>
<!-- SPRING-BOOT ... -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<type>pom</type>
<version>${org.springframework.boot-version}</version>
<scope>import</scope>
</dependency>
....
我还尝试添加 <hibernate.version>5.0.11.Final</hibernate.version>
进入子模块 pom.也没有变化。
我错过了什么?
最佳答案
属性覆盖仅在将 spring-boot 声明为父级时才有效。
使用以下内容(取自 Spring-Boot documentation ):
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- Inherit defaults from Spring Boot -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.8.RELEASE</version>
</parent>
<groupId>com.example</groupId>
<artifactId>myproject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<hibernate.version>5.0.11.Final</hibernate.version>
</properties>
<!-- Add typical dependencies for a web application -->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<!-- Package as an executable jar -->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
关于hibernate - Spring Boot 覆盖第三方依赖版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40329625/