Spring Boot 3.0.2项目启动失败:configurationPropertiesBeans创建异常求助
解决Spring Boot 3.0.2 WebFlux项目启动BeanCreationException(找不到ConfigurationBeanFactoryMetadata类)
问题原因
org.springframework.boot.context.properties.ConfigurationBeanFactoryMetadata类在Spring Boot 3.0及以上版本中已被移除,出现该错误的核心原因是项目存在依赖冲突:要么是混用了低于3.0版本的Spring Boot Starter依赖,要么是第三方依赖仍在引用旧版本的Spring Boot组件,导致启动时尝试加载已不存在的类。
解决方案步骤
1. 统一Spring Boot版本
确保所有Spring Boot相关依赖版本与项目使用的3.0.2保持一致,通过spring-boot-starter-parent统一管理版本是最稳妥的方式:
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>3.0.2</version> <relativePath/> </parent>
所有Spring Boot Starter依赖(如spring-boot-starter-webflux)无需手动指定版本,会自动继承parent的版本。
2. 排查并修复第三方依赖冲突
用Maven依赖树命令找出引入旧版本Spring Boot组件的依赖:
mvn dependency:tree
在输出结果中搜索spring-boot-context-properties或包含ConfigurationBeanFactoryMetadata的条目,找到对应第三方依赖后,排除其传递的旧版本Spring Boot依赖。示例:
<dependency> <groupId>第三方依赖groupId</groupId> <artifactId>第三方依赖artifactId</artifactId> <version>对应版本号</version> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </exclusion> </exclusions> </dependency>
3. 清理缓存并重新构建
执行命令清理本地缓存并重新构建项目,避免旧依赖残留:
mvn clean install -U
同时同步IDE的依赖(如IntelliJ右键项目→Maven→Reload Project)。
验证
修改完成后重新启动项目,若不再抛出BeanCreationException且项目正常启动,说明问题已解决。
内容的提问来源于stack exchange,提问作者S.R.D
相关产品推荐
相关产品推荐

