【已解决】Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.properties.

2022-07-11 16:01:36 浏览数 (1)

一、前言

最近小编在学习springcloud的项目知识,初出茅庐,跟着视频敲,发现不对劲。视频出的时间太早了,导致和现在的SpringBoot版本不一样,这是个头疼的问题,一个不小心就版本不兼容。击退你的学习信心的往往不是复杂的技术和业务,而是简简单单的环境版本问题。下面跟着小编一起解决问题吧!!

二、报错信息(省略部分)

代码语言:javascript复制
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.context.properties.ConfigurationPropertiesBeans]: Factory method 'configurationPropertiesBeans' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.10.jar:5.3.10]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.10.jar:5.3.10]
	... 34 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
	at org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration.configurationPropertiesBeans(ConfigurationPropertiesRebinderAutoConfiguration.java:56) ~[spring-cloud-context-2.1.3.RELEASE.jar:2.1.3.RELEASE]
	at org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$1b4f1aed.CGLIB$configurationPropertiesBeans$2(<generated>) ~[spring-cloud-context-2.1.3.RELEASE.jar:2.1.3.RELEASE]
	at org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$1b4f1aed$$FastClassBySpringCGLIB$$92bb4cd3.invoke(<generated>) ~[spring-cloud-context-2.1.3.RELEASE.jar:2.1.3.RELEASE]
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.3.10.jar:5.3.10]
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.3.10.jar:5.3.10]
	at org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$1b4f1aed.configurationPropertiesBeans(<generated>) ~[spring-cloud-context-2.1.3.RELEASE.jar:2.1.3.RELEASE]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.10.jar:5.3.10]
	... 35 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.properties.ConfigurationBeanFactoryMetadata
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_121]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_121]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_121]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_121]
	... 46 common frames omitted

Disconnected from the target VM, address: '127.0.0.1:53071', transport: 'socket'

Process finished with exit code 1

三、解决问题

不难发现是因为Springboot和SpringCloud版本不兼容,我们打开:--->Spring Cloud官网,找到对应的版本对照,果然官网不会骗人哈,这样就可以解决问题了。大家跟着自己的版本进行对照选择!!

这里不是很详细,我们可以去Github上看详细版的:--->==springboot与springcloud详细对照信息==

小编的是根据视频的springboot版本是==2.1.8==,所以对应==Greenwich.SR6==

四、总结

找了这么久恍然发现,一定要看官网,不然你要走好多弯路。


Q.E.D.

0 人点赞