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

导读:本篇文章讲解 【已解决】Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.properties.,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

一、前言

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

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

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
在这里插入图片描述

四、总结

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


推广自己网站时间到了!!!

点击访问!欢迎访问,里面也是有很多好的文章哦!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由半码博客整理,本文链接:https://www.bmabk.com/index.php/post/85219.html

(0)

相关推荐

半码博客——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!