当前位置:
首页 >
行业知识 >
SpringBoot:解决Property ‘spring.profiles‘ imported from location ‘class path resource 问题
行业知识
SpringBoot:解决Property ‘spring.profiles‘ imported from location ‘class path resource 问题
2026-12-01 13:39:00
来源:互联网转载
一、在学习SpringBoot配置profile的时候,.yml文件内容明明跟老师敲的一模一样,但还是报org.springframework.boot.context.config.InvalidConfigDataPropertyException: Property 'spring.profiles' imported from location 'class path resource [application.yml]' is invalid and should be replaced with 'spring.config.activate.on-profile' [origin: class path resource [application.yml] - 21:13]错误
二、.yml文件源代码
---server: port: 8081spring: profiles: dev---server: port: 8082spring: profiles: pro---server: port: 8083spring: profiles: test---spring: profiles: active: test
三、报如下错误
四、问题原因
通�index.php/tags-41973.html" >�Debug运行提示: should be replaced with 'spring.config.activate.on-profile'(需要你改为现在的这种代码格式)
五、改完后源代码
---server: port: 8081spring: config: activate: on-profile: dev---server: port: 8082spring: config: activate: on-profile: pro---server: port: 8083spring: config: activate: on-profile: test---spring: profiles: active: test
六、运行结果
七、反思
当按照老师讲的走时,遇到问题,需要及时通过Debug提示信息来找错误,不要***脑筋,一直检查代码错误。这次问题出在版本的原因。
我们需要养成会看代码提示来进行解决问题的习惯,脑子要灵活点。
上一篇:网址服务器地址怎么查询?