Property ‘spring.profiles.active’ imported from location ‘class path resource [X.yml]’ is invalid in a profile specific resource [origin: class path resource [X.yml] Springboot 配置 多配置文件报错简单解决方法
这里不探究深入的问题 只提供一个最简单的方法
在properties中加这个
spring.config.use-legacy-processing=true
# 你之前的配置项
yml的例子
这样运行起来就是走的application-shequ.yml了
实际上yml和properties应该可以交叉着用 没什么影响(未测试,请以实际情况为准)
问题原因和来源
是springboot版本更新带来的问题
见官方说明
Spring Boot 2.4 has provided an overhaul of the way that application.properties and application.yml files are processed. The updated logic has been designed to simplify and rationalize the way that external configuration is loaded. It has also allowed us to provide new features, such as spring.config.import support.
The updated design intentionally restricts certain property combinations. This means that you may need to change a few things when upgrading from Spring Boot 2.3 or earlier.