Andrew
Andrew

Reputation: 55

Dependency mismatch between spring boot and spring cloud

I am getting the following exception when building spring boot application.

java.lang.IllegalStateException: Failed to load ApplicationContext

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configurationPropertiesBeans' defined in class path resource [org/springframework/cloud/autoconfigure/ConfigurationPropertiesRebinderAutoConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.cloud.context.properties.ConfigurationPropertiesBeans] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@512ddf17]

Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.cloud.context.properties.ConfigurationPropertiesBeans] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@512ddf17]

Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata

Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.properties.ConfigurationBeanFactoryMetadata

my pom.xml file is:

    <properties>
        <kotlin.version>1.5.32</kotlin.version>
        <spring-boot.version>2.5.7</spring-boot.version>
        <spring-cloud.version>Hoxton.SR12</spring-cloud.version>
    </properties>
    .
    .
    .
    <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>

I also tried spring cloud version 2020.0.3 as suggested here: https://spring.io/projects/spring-cloud

but still the same problem. I'd really appreciate any help.

Upvotes: 3

Views: 5183

Answers (1)

Caffeine Coder
Caffeine Coder

Reputation: 1146

I had the similar situation as yours, where I was using following versions-

 <spring-boot-starter.version>2.7.6</spring-boot-starter.version>
 <spring-cloud-aws.version>2.2.6.RELEASE</spring-cloud-aws.version>
 <spring-cloud.version>Hoxton.SR12</spring-cloud.version>

I added following dependency under dependency managemenent-

 <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-dependencies</artifactId>
        <version>2020.0.3</version>
        <type>pom</type>
        <scope>import</scope>
  </dependency>

it worked like a charm.

Upvotes: 2

Related Questions