4
votes

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>
2
You overriding in child, as from parent perspective there is nothint to override.Antoniossss
@Antoniossss what do you mean? I need the dependencies in the child project to be version 2.1.4 but they all remain at 1.5.18userTN
You will need to change the parent of your custom parent to version 2.1.4.RELEASE as well. There might be a way to force things, but mixing 2 Spring Boot versions like that is likely to have all kinds of weird errors.Wim Deblauwe
@WimDeblauwe that's what I was trying to avoid. because not all the child projects need to be updated to spring boot 2userTN

2 Answers

0
votes

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.

0
votes

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.