我正在尝试将本机和保管库配置文件与配置服务器后端混合:
spring:
profiles:
active: native, vault
cloud:
config:
server:
native:
searchLocations: classpath:/abc
vault:
kv-version: 2
当我启动配置服务器时,我 curl 获取属性:
curl -X "GET" "http://localhost:20000/appName/dev" -H "X-Config-Token: xxxxxxxx"
我有空的 propertySources 列表:
{"name":"appName","profiles":["dev"],"label":null,"version":null,"state":null,"propertySources":[]}%
但是当我更改我的引导文件(删除保险库配置文件)时:
spring:
profiles:
active: native
cloud:
config:
server:
native:
searchLocations: classpath:/abc
vault:
kv-version: 2
它有效:返回我的属性:
{"name":"appName","profiles":["dev"],"label":null,"version":null,"state":null,"propertySources":[{"name":"classpath:/abc/appName-dev.yml","source":{"some.properties":"VALUE","....}
我确实尝试过使用“订单”标志,但仍然没有...
我发现的唯一解决方法是使用“复合”配置文件进行引导,如下所示:
spring:
profiles:
active: composite
cloud:
config:
server:
composite:
-
type: vault
kv-version: 2
-
type: native
searchLocations: classpath:/abc
但是仍然不知道为什么它不适用于多配置文件配置,以及为什么 vault 会覆盖我的本机属性....