0

我正在尝试从连接到 2 个源的配置服务器获取我的微服务配置:git 和 vault(用于机密)。我有下面的配置:在配置服务器中:

server:
  port: 8888

spring:
  profiles:
    active: git, vault
  cloud:
    config:
      server:
        vault:
          port: 8200
          host: 127.0.0.1
          kvVersion: 2
        git:
          order: 2
          uri: git@gitlab.git

在 bootstrap.yml 的客户端:

spring:
  application:
    name: my-service-name

  cloud:
    config:
      uri: http://localhost:8888
      token: //token
      label: dev

但在我的保险库中,我有这样的路径:

secret/cad
     |--my-service-name

当我直接在其中制作我的秘密时,/secret/my-service-name我可以访问我的秘密,但是我如何配置对秘密的访问:/secret/cad/my-service-name

谢谢你。

4

1 回答 1

0

您可以创建实现 VaultConfigurer 的自定义配置类,您可以在其中覆盖自定义路径

@Configuration 公共类 CustomVaultConfiguraton 实现 VaultConfigurer {

 @override
 public void addSecretsBackends(SecretBackendConfigurer configures){

 configures.add("customPath");

} }

在 spring.factories org.springframework.cloud.bootstrap.BootstrapConfiguration=\packagename.CustomVaultConfiguration 添加上面的配置类

于 2020-10-30T17:42:39.460 回答