Spring Cloud Config 发现自以为是的bug之旅

最近开始学习Sping Cloud,在学习Spring Cloud Config的过程中,发现如果想加载本地的配置文件,需要启用spring.profiles.active=native。
完整配置:

1
2
3
4
5
6
7
8
9
10
spring:
application:
name: microservice-config
profiles:
active: native
cloud:
config:
server:
native:
search-locations: file:///H://workspace//microservice-config-repo

但是又使用了多环境配置多环境配置,如:

1
2
3
4
5
6
7
8
9
  ---
spring:
profiles: local
---
spring:
profiles: dev
---
spring:
profiles: pro

刚开始,我认为多环境与配置中心的配置他俩有冲突,因为使用了多环境就没法使用native。还自以为是的认为这是一个bug,跑到spring cloud config的git issue录了个问题https://github.com/spring-cloud/spring-cloud-config/issues/757。

后来发现原来spring.profiles.active 可以设置多个值,使用“,”分隔,无先后顺序。