春云无法将金库秘密解析为.yml



我正在使用微服务架构,并拥有spring-cloud-config服务和另一个微服务。

profiles:
active: vault
cloud:
# Configuration for a vault server running in dev mode
vault:
scheme: http
host: 127.0.0.1
port: 8200
connection-timeout: 5000
read-timeout: 15000
authentication: TOKEN
token: s.E4gdoIYAKxMvCE56MP5Etmvy
kv:
enabled: true
backend: secret
backend-version: 2
profile-separator: /
generic:
enabled: false
application-name: myapp

配置服务器依赖

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-vault-config</artifactId>
<version>2.1.5.RELEASE</version>
</dependency>

这是到配置服务的.yml。然后在我的微服务的.yml中,我有db.username属性,我想从Vault中解析它,但我做不到。你有什么想法吗?

username: db.username
password: secret/apm-transaction-service/dev/db.user
@Value("${db.username}")

该值被解析为java代码,但没有解析为.yml

现在,对于我拥有的每一个微服务,我都想在不对微服务进行任何更改的情况下解决配置服务的秘密。当前正在从配置服务读取本机.ymls,并希望再添加一个源:(

ApplicationStartupRunner运行方法已启动!!根

如果您使用的是spring-boot,那么要解析.yml文件中的值,它必须是一个变量。您必须在yaml文件中使用${db.username}

最新更新