启动springboot应用程序时bean创建错误
当我尝试运行 Spring Boot 应用程序时,出现此异常:
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@3764951d]
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@3764951d]
我认为是版本不兼容。我在我的 pom.xml 中导入了 open feign,之后它不起作用,但我不知道如何解决这个问题。我使用 open feign 2.2.5.RELEASE。这是我的 pom.xml:
回答
为了详细说明@M-deinum 的评论,将 Spring Boot 版本设置为2.3.4.RELEASE(而不是2.4.2我的情况)解决了这个问题。在gradle此意味着改变:
plugins {
id 'org.springframework.boot' version '2.4.2'
...
}
到
plugins {
id 'org.springframework.boot' version '2.3.4.RELEASE'
...
}
回答
所以这似乎是 SpringBoot 与云服务版本兼容性问题。有没有一点可以让我们看到整个 Spring 框架伞的版本兼容性矩阵?谢谢!
- https://spring.io/projects/spring-cloud
回答
您需要将 spring boot 版本更改为 Released 版本
从
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
到
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>