运行Spring Boot应用时出现PropertyPlaceholderAutoConfiguration类找不到异常求助
解决Spring Boot启动时
PropertyPlaceholderAutoConfiguration找不到的问题 嗨,我来帮你搞定这个启动异常!从你贴的错误信息和pom.xml来看,问题的核心是Spring Cloud版本冲突,导致依赖的Spring Boot版本不匹配,进而找不到对应的类。
问题根源分析
你的pom里有两处版本不统一的配置,这直接导致了依赖混乱:
- 项目parent用的是
spring-cloud-starter-parent的Brixton.RELEASE版本,这个版本对应的Spring Boot是1.3.x系列 - 但在
dependencyManagement里又导入了spring-cloud-dependencies的Edgware.RELEASE版本,它对应的Spring Boot是1.5.x系列
而org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration这个类,是Spring Boot 1.4及以后版本才挪到这个包路径下的——在1.3.x版本里,它的包名是org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration。版本冲突让项目不知道该加载哪个版本的依赖,自然就找不到正确的类了。
具体解决方案
你只需要统一Spring Cloud的版本,确保parent和dependencyManagement的版本匹配就行,这里给你两个可行方案:
方案1:切换到Edgware.RELEASE版本(推荐)
如果可以升级,建议把parent换成Spring Boot的官方parent,再搭配Edgware的Spring Cloud依赖:
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.22.RELEASE</version> <!-- 这是Edgware对应的稳定Spring Boot版本 --> <relativePath/> </parent>
然后保留dependencyManagement里的配置不变:
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Edgware.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
方案2:保留Brixton.RELEASE版本
如果不想升级,那就把dependencyManagement里的Spring Cloud版本改成和parent一致:
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Brixton.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
验证步骤
改完配置后,记得做这些操作确保依赖正确:
- 执行
mvn clean install清理旧的依赖并重新构建项目 - 可以去
target/dependency目录下看看spring-boot-autoconfigure.jar的版本,确认和你选择的Spring Boot版本一致 - 重新启动应用,应该就能正常运行了
内容的提问来源于stack exchange,提问作者Chintamani
相关产品推荐
相关产品推荐

