iis服务器助手广告
返回顶部
首页 > 资讯 > 后端开发 > JAVA >SpringBoot:解决Property ‘spring.profiles‘ imported from location ‘class path resource 问题
  • 132
分享到

SpringBoot:解决Property ‘spring.profiles‘ imported from location ‘class path resource 问题

springbootspringjava 2023-09-07 13:09:53 132人浏览 安东尼
摘要

一、在学习SpringBoot配置profile的时候,.yml文件内容明明跟老师敲的一模一样,但还是报org.springframework.boot.context.config.InvalidConfigDataPropertyExc

一、在学习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

三、报如下错误

四、问题原因

通过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提示信息来找错误,不要死脑筋,一直检查代码错误。这次问题出在版本的原因。

我们需要养成会看代码提示来进行解决问题的习惯,脑子要灵活点。 

来源地址:https://blog.csdn.net/weixin_54280370/article/details/129966091

--结束END--

本文标题: SpringBoot:解决Property ‘spring.profiles‘ imported from location ‘class path resource 问题

本文链接: https://www.lsjlt.com/news/398285.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作