解决:Error creating bean with name ‘bootstrapImportSelectorConfiguration‘,版本冲突

项目启动时出现BeanCreationException,错误原因是SpringBoot与SpringCloud版本不兼容。具体表现为NoClassDefFoundError,找不到ConfigurationPropertiesBean类。解决方案是查找并更新SpringBoot版本,使其与SpringCloud版本对应。将SpringBoot从2.1.10.RELEASE更新到2.5.8后,项目成功启动。

说明

今天在写springcloud项目的时候项目启动报错,报错信息如下

2023-05-18 14:44:51.754 ERROR 9252 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bootstrapImportSelectorConfiguration': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationPropertiesBean
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:847) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) [spring-boot-2.1.10.RELEASE.jar:2.1.10.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) [spring-boot-2.1.10.RELEASE.jar:2.1.10.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.1.10.RELEASE.jar:2.1.10.RELEASE]
	at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:140) [spring-boot-2.1.10.RELEASE.jar:2.1.10.RELEASE]
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:197) [spring-cloud-context-3.0.4.jar:3.0.4]
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:114) [spring-cloud-context-3.0.4.jar:3.0.4]
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:77) [spring-cloud-context-3.0.4.jar:3.0.4]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) [spring-context-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) [spring-context-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) [spring-context-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) [spring-context-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:76) [spring-boot-2.1.10.RELEASE.jar:2.1.10.RELEASE]
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53) [spring-boot-2.1.10.RELEASE.jar:2.1.10.RELEASE]
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:342) [spring-boot-2.1.10.RELEASE.jar:2.1.10.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:305) [spring-boot-2.1.10.RELEASE.jar:2.1.10.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.1.10.RELEASE.jar:2.1.10.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) [spring-boot-2.1.10.RELEASE.jar:2.1.10.RELEASE]
	at com.pug.order.OrderApplication.main(OrderApplication.java:23) [classes/:na]
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationPropertiesBean
	at org.springframework.cloud.context.properties.ConfigurationPropertiesBeans.postProcessBeforeInitialization(ConfigurationPropertiesBeans.java:76) ~[spring-cloud-context-3.0.4.jar:3.0.4]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:414) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	... 26 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.properties.ConfigurationPropertiesBean
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_202]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_202]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[na:1.8.0_202]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_202]
	... 30 common frames omitted

问题原因

SpringBoot与SpringCloud的版本不匹配。

问题解决

上网查询SpringBoot与SpringCloud的对应版本

Finchley.M2Spring Boot >=2.0.0.M3 and <2.0.0.M5
Finchley.M3Spring Boot >=2.0.0.M5 and <=2.0.0.M5
Finchley.M4Spring Boot >=2.0.0.M6 and <=2.0.0.M6
Finchley.M5Spring Boot >=2.0.0.M7 and <=2.0.0.M7
Finchley.M6Spring Boot >=2.0.0.RC1 and <=2.0.0.RC1
Finchley.M7=====>Spring Boot >=2.0.0.RC2 and <=2.0.0.RC2
Finchley.M9=====>Spring Boot >=2.0.0.RELEASE and <=2.0.0.RELEASE
Finchley.RC1=====>Spring Boot >=2.0.1.RELEASE and <2.0.2.RELEASE
Finchley.RC2=====>Spring Boot >=2.0.2.RELEASE and <2.0.3.RELEASE
Finchley.SR4=====>Spring Boot >=2.0.3.RELEASE and <2.0.999.BUILD-SNAPSHOT
Finchley.BUILD-SNAPSHOT=====>Spring Boot >=2.0.999.BUILD-SNAPSHOT and <2.1.0.M3
Greenwich.M1=====>Spring Boot >=2.1.0.M3 and <2.1.0.RELEASE
Greenwich.SR5=====>Spring Boot >=2.1.0.RELEASE and <2.1.14.BUILD-SNAPSHOT
Greenwich.BUILD-SNAPSHOT=====>Spring Boot >=2.1.14.BUILD-SNAPSHOT and <2.2.0.M4
Hoxton.SR3=====>Spring Boot >=2.2.0.M4 and <2.3.0.BUILD-SNAPSHOT
Hoxton.BUILD-SNAPSHOTS=====>pring Boot >=2.3.0.BUILD-SNAPSHOT
Hoxton.SR12=====>Spring Boot >=2.2.0.RELEASE and <2.4.0.M1,
2020.0.4=====>Spring Boot >=2.4.0.M1 and <2.5.8-SNAPSHOT",
2020.0.5-SNAPSHOT=====>Spring Boot >=2.5.8-SNAPSHOT and <2.6.0-M1",
2020.0.6=====>Spring Boot >=2.4.0.M1 and <2.6.0-M1,
2021.0.0-M1=====>Spring Boot >=2.6.0-M1 and <2.6.0-M3,
2021.0.0-M3=====>Spring Boot >=2.6.0-M3 and <2.6.0-RC1,
2021.0.0-RC1=====>Spring Boot >=2.6.0-RC1 and <2.6.1,
2021.0.7=====>Spring Boot >=2.6.1 and <3.0.0-M1,
2022.0.0-M1=====>Spring Boot >=3.0.0-M1 and <3.0.0-M2,
2022.0.0-M2=====>Spring Boot >=3.0.0-M2 and <3.0.0-M3,
2022.0.0-M3=====>Spring Boot >=3.0.0-M3 and <3.0.0-M4,
2022.0.0-M4=====>Spring Boot >=3.0.0-M4 and <3.0.0-M5,
2022.0.0-M5=====>Spring Boot >=3.0.0-M5 and <3.0.0-RC1,
2022.0.0-RC1=====>Spring Boot >=3.0.0-RC1 and <3.0.0-RC2,
2022.0.0-RC2=====>Spring Boot >=3.0.0-RC2 and <3.0.0,

或者访问spring官网进行查看
地址如下:
https://start.spring.io/actuator/info

看看我项目的配置,如下图:
在这里插入图片描述
在这里插入图片描述
我使用的SpringCloud版本是:2020.0.4,应该对应的springboot版本是2.4.0.M1到2.5.7-SNAPSHOT,但是我的项目中使用的是2.1.10.RELEASE所有启动会有问题。

然后我就把SpringBoot的版本改成了2.5.8启动就正常了。
在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值