Springboot 多配置文件 报错 简单解决方法

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.

资料来源
链接: Spring Boot Config Data Migration Guide

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值