Search code examples
javaspring-bootmavenspring-cloud

Spring Dependency Mess - conflict with Spring Boot 2.5.4 and Spring Cloud 3.0.3


I am trying to update an application which already pulls in the kitchen sink (or perhaps a few, they're joined at the hip) and I am sorting through version conflicts.

I want to update to Spring Boot 2.5+ and also use Spring Cloud Consul - I am attempting to pull in:

  1. spring-cloud-starter-consul-discovery:3.0.3
  2. spring-boot:2.5.4

For bonus points, within spring-cloud-starter-consul-discovery, I am seeing that it pulls in reactor-core:3.4.6 and at the same time reactor-extra:3.4.3 (which pulls in reactor-core:3.4.5). The list goes on and on ...

  1. https://search.maven.org/artifact/org.springframework.cloud/spring-cloud-starter-consul-discovery/3.0.3/jar - original point of contention is that it pulls in spring boot 2.4.6 ... it was advertised as supporting 2.5+, then shouldn't the version reference 2.5+?

  2. https://search.maven.org/artifact/org.springframework.cloud/spring-cloud-loadbalancer/3.0.3/jar - this to me is just plain laziness, right below reactor-core is reactor-extra, why wouldn't the Spring developers make extra pull in the same version of core? See: https://search.maven.org/artifact/io.projectreactor.addons/reactor-extra/3.4.3/jar

While this is a trivial problem to solve, it shouldn't be my problem. Am I missing something, or is this just the way it is and I shouldn't expect more?


Solution

  • First of all, you need to look at this compatibility matrix between cloud and boot dependencies. Then, you need (for example) to generate your bom, where you import

    These boms, internally, either import other boms, like for example consul, the one you are interested in, which is at version 2.2.8.RELEASE. Look in the properties tag in that file and see this:

    <spring-cloud-consul.version>2.2.8.RELEASE</spring-cloud-consul.version>
    

    specifically:

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-consul-dependencies</artifactId>
        <version>${spring-cloud-consul.version}</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
    

    You can then look at the specific consul bom and see that the version consul-discovery is:

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-consul-discovery</artifactId>
        <version>${project.version}</version>
    </dependency>
    

    Same pattern to find out what version is where can be done for reactor dependencies.


    From my 10 minutes investing into this, I don't see a version of spring-cloud-starter-consul-discovery:3.0.3 that would be included in a cloud-dependecies.

    You could still try to force a certain version of a dependency. We just recently had such a problem in spring-cloud-kubernetes, internally.

    This may or may not work, though.