失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > SpringCloud 多环境配置文件读取失败

SpringCloud 多环境配置文件读取失败

时间:2019-04-09 07:37:05

相关推荐

SpringCloud 多环境配置文件读取失败

nacos配置多环境,使用时发现环境切换的代码不生效

server:port: 8066servlet:contextPath: /room-pricespring:profiles:active: devapplication:name: room-price-webjackson:default-property-inclusion: non_null---spring:cloud:nacos:discovery:server-addr: :8848namespace: xxxconfig:server-addr: :8848namespace: xxxfile-extension: yamlgroup: DEFAULT_GROUPprofiles:active: dev---spring:cloud:nacos:discovery:server-addr: :8848namespace: xxxconfig:server-addr: :8848namespace: xxxfile-extension: yamlgroup: DEFAULT_GROUPprofiles:active: test---spring:cloud:nacos:discovery:server-addr: :8848namespace: xxxconfig:sserver-addr: :8848namespace: xxxfile-extension: yamlgroup: DEFAULT_GROUPprofiles:active: pro

问题解决

发现是springBoot版本问题,SpringBoot2.4之后代码进行升级了,项目中使用的版本是

<spring-boot.version>2.4.12</spring-boot.version>

原来profiles配置

spring: profiles:active: test

现在可以正常运行的配置

spring: # profiles:# active: testconfig:activate:on-profile: test

官方文档

如果觉得《SpringCloud 多环境配置文件读取失败》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。