6

I am using Spring Boot 2.5.5 with Spring Cloud Version 2020.0.4 but when I am trying to run the application I am getting below exception -

Exception encountered during context initialization - cancelling refresh attempt:     
org.springframework.beans.factory.BeanCreationException: Error creating bean with name  
'compositeCompatibilityVerifier' defined in class path resource [org/springframework 
/cloud/configuration/CompatibilityVerifierAutoConfiguration.class]: Bean instantiation  
via factory method failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[org.springframework.cloud.configuration.CompositeCompatibilityVerifier]: Factory 
 method 'compositeCompatibilityVerifier' threw exception; nested exception is 
 org.springframework.cloud.configuration.CompatibilityNotMetException

pom.xml

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

<properties>
    <java.version>1.8</java.version>
    <spring-cloud.version>2020.0.4</spring-cloud.version>
</properties>

<dependencies>
    <!-- Below jar file also has same Spring Boot Version -->
    <dependency>
        <groupId>com.another.project</groupId>
        <artifactId>commons</artifactId>
        <version>1</version>
        <scope>compile</scope>
    </dependency>

    <!-- other spring boot dependency -->
</dependencies>

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

I have another project jar included in pom which also has same Spring Boot Version that I doubt cause the issue but not sure how?

ppb
  • 2,299
  • 4
  • 43
  • 75

3 Answers3

1

Your pom looks good. The only thing I would suggest is to check the spring components compatibility. The spring.io page you have a compatibility matrix, and you should double-check is the version you are trying to use compatible with spring boot.

Second thing you may try, is to not have a parent POM at all, but import spring boot, and spring cloud dependencies from their pom-s.

You added spring cloud, for spring boot do:

<dependencyManagement>
     <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>${spring-boot.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring-cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
Augustin Ghauratto
  • 1,420
  • 1
  • 19
  • 21
0

I had the same issue , when i used spring-cloud.version : 2020.0.3 and resolved it by using the version

<spring-cloud.version>2021.0.3</spring-cloud.version>

Nandan
  • 497
  • 2
  • 7
  • 18
0

Check out the compatibility of the spring-cloud you are using with your spring-boot version: Spring-Cloud

Brian Brix
  • 449
  • 4
  • 12