Spring 引导覆盖第三方依赖版本

Spring Boot Overwrite Third-PartyDependency Version

我有一个 Spring Boot 1.3.8 的多模块项目。目前我想更新到 1.4.1,但目前很痛苦,因为几乎没有其他主要升级,如 querydsl、thyemeleaf、hibernate。

所以我找到了可以将 Hibernate 5 与 Spring Boot 1.3.8 一起使用的信息,您只需要在属性中覆盖 hibernate 的版本号。 (示例:

我在父 Pom 中做了:

<properties>
    <hibernate.version>5.0.11.Final</hibernate.version>
    ...
</properties>

这是同一个 pom,其中 spring 引导依赖项在依赖项管理下声明:

<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.xml 中。也没有变化。

我错过了什么?

属性 覆盖仅在将 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>