talha_norat
talha_norat

Reputation: 96

Override spring-boot version from parent POM

I have multiple spring projects that all have the same custom parent POM from which they all inherit their spring-boot version (1.5.18.RELEASE). Only one of the child projects need to be updated to version 2.1.4.RELEASE, but when I import spring-boot-dependencies, the spring-boot dependencies in the child project still remain at version 1.5.18.RELEASE.

Custom Parent POM:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.18.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

<groupId>com.example</groupId>
<artifactId>services</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Services :: Parent</name>
<description>Parent Project for Services</description>

Child POM:

<parent>
    <artifactId>services</artifactId>
    <groupId>com.example</groupId>
    <version>0.0.1-SNAPSHOT</version>
    <relativePath>../services/pom.xml</relativePath>
</parent>

<dependencyManagement>
    <dependencies>
        <dependency>
            <!-- Import dependency management from Spring Boot -->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>2.1.4.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Upvotes: 5

Views: 9656

Answers (2)

Karol Dowbecki
Karol Dowbecki

Reputation: 44970

spring-boot-starter-parent not only defines dependencies but also configures plugins and ships properties. Because you are upgrading from Spring Boot 1.5.X to Spring Boot 2.X it most likely won't be enough just to bump versions, there are incompatible changes between major releases e.g. Spring Boot 1.5.X is Java 6+ but Spring Boot 2.X is Java 8+.

You should use spring-boot-starter-parent-2.1.4.RELEASE as a parent in your child pom.xml. Your current approach is tinkering, follow the Spring Boot docs and set up child module as a proper Spring Boot 2.X module or you will waste a lot of time debugging problems caused by partial setup.

Upvotes: 0

David Enoma
David Enoma

Reputation: 311

You have to update the parent to the 2.1.4.release. This is because there can be lots of development problems if the child and parent are not in sync. Tip: You can delete the version tag in the child dependencies.

Upvotes: 0

Related Questions