今天在跟着视频弄谷粒商城时遇到一个坑,记录一下(一天天的踩的坑是真多)
报错太长所以只截取了一部分
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2024-02-02 12:11:48.424 ERROR 10496 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configurationPropertiesBeans' defined in class path resource [org/springframework/cloud/autoconfigure/ConfigurationPropertiesRebinderAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is 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.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.10.jar:5.3.10]
在网上和问过chatgpt后,发现问题在于pom配置的springcloud和springboot版本的问题,好像还有java版本的问题
在springcloud官网(Spring Cloud)查看后,修改到对应的配置解决了问题。
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.atguigu.guli</groupId>
<artifactId>guli-product</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>guli-product</name>
<description>product</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>2021.0.3</spring-cloud.version>
</properties>