今天在项目中配置nacos的时候,发现启动一直报错,如下所示
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 [sun.misc.Launcher$AppClassLoader@18b4aac2]
然后发现应该是哪里的依赖有问题
<dependencyManagement> <dependencies> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-alibaba-dependencies</artifactId> <version>2.2.5.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
<dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> </dependency>
我在pom文件中添加了这一个依赖就跑不起来了,后来我发现应该是cloud版本与boot版本不兼容,我在父模块的boot依赖是这样的
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.7.16</version> <relativePath/> </parent>
当我把2.7.16换成2.3.2.RELEASE之后就正常启动了,下次遇到依赖问题,尤其要主要boot与cloud的版本兼容