Spring Boot覆盖第三方依赖版本

时间:2016-10-30 13:28:20

标签: hibernate spring-boot dependencies version upgrade

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

所以我找到了可以在Spring Boot 1.3.8中使用Hibernate 5的信息,你只需要在属性中覆盖hibernate的版本号。 (例如:enter link description here

我在父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>

            ....

在我的子模块中,我仍然有 enter image description here

我还尝试将<hibernate.version>5.0.11.Final</hibernate.version>添加到子模块pom中。也没有变化。

我错过了什么?

1 个答案:

答案 0 :(得分:2)

属性覆盖仅在将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>
相关问题