Michael Hegner
Michael Hegner

Reputation: 5823

Spring Boot Overwrite Third-PartyDependency Version

I have a multimodule project with Spring Boot 1.3.8. Currently I want to update to 1.4.1 but it is currently pain, because of few other major upgrades like querydsl, thyemeleaf, hibernate.

So I found information you could use Hibernate 5 with Spring Boot 1.3.8 and you need only to overwrite the version number of hibernate in the properties. (Example: enter link description here)

I did in the Parent Pom:

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

It is the same pom where spring boot dependencies are declared under dependency management:

<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>

            ....

In my submodule I still have enter image description here

I also tried to add <hibernate.version>5.0.11.Final</hibernate.version> into the sub modules pom. No change, too.

What am I missing?

Upvotes: 2

Views: 3194

Answers (1)

alexbt
alexbt

Reputation: 17045

The property override would only work when declaring spring-boot as parent.

Use the following (taken from 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>

Upvotes: 2

Related Questions