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 多环境配置文件读取失败》对你有帮助,请点赞、收藏,并留下你的观点哦!