Error creating bean with name 'compositeCompatibilityVerifier'

Viewed 5113

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?

2 Answers

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>

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>

Related