Sping Boot 和Spring Cloud之间的依赖关系不匹配

atmip9wb  于 2022-12-10  发布在  Spring
关注(0)|答案(1)|浏览(156)

我在构建Sping Boot 应用程序时遇到以下异常。

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

我的pom.xml文件是:

<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>

我也尝试了这里建议的Spring Cloud版本2020.0.3:https://spring.io/projects/spring-cloud
但还是一样的问题,我真的很感激你的帮助

ht4b089n

ht4b089n1#

我的情况和你的类似,我使用的是以下版本-

<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>

我在依赖项管理下添加了以下依赖项-

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

它的效果非常好。

相关问题