簡體   English   中英

Spring 雲庫配置文件特定引導程序

[英]Spring Cloud Vault Profile Specific Bootstrap

我有一個 Spring 引導應用程序,我想根據我正在運行的配置文件從 Vault 加載配置。 目前我有 2 個配置文件(開發、產品)。 我的 Dev Profile 使用 H2 數據庫,而 Prod Profile 使用 Posgres DB。 運行開發配置文件會從 Vault 加載正確的配置,但使用 Prod 配置文件運行似乎會以某種方式跳過它,而不是查看 Vault。

引導程序.yaml

spring:
  application:
    name: my-app
  profiles:
    active:
  cloud:
    vault:
      host: localhost
      port: 8200
      scheme: http
      uri: http://localhost:8200
      connection-timeout: 5000
      read-timeout: 15000
      authentication: TOKEN
      token: 00000000-0000-0000-0000-000000000000
      kv:
        enabled: true
        backend: secret
        default-context: my-app/dev
      fail-fast: false

引導-prod.yaml

spring:
  application:
    name: gateway
  profiles:
    active: prod
  cloud:
    vault:
      host: localhost
      port: 8200
      scheme: http
      uri: http://localhost:8200
      connection-timeout: 5000
      read-timeout: 15000
      authentication: TOKEN
      token: 00000000-0000-0000-0000-000000000000
      kv:
        enabled: true
        backend: secret
        default-context: my-app/dev
      fail-fast: false

例如,運行命令gradle將從保管庫加載配置。 但是運行gradle -Pprod無法從 Vault 加載正確的配置。

在使用 gradle 時嘗試使用以下語法來激活您的配置文件:

./gradlew clean bootRun --args='--spring.profiles.active=prod'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM