1. 程式人生 > >Spring Cloud Consul—git2consul與配置

Spring Cloud Consul—git2consul與配置

form 需要 mas con fast 存儲 可能 develop 而不是

git2consul是一個Consul社區項目,將文件從git存儲庫加載到各個密鑰到Consul。默認情況下,密鑰的名稱是文件的名稱。YAML和Properties文件分別支持.yml和.properties的文件擴展名。將spring.cloud.consul.config.format屬性設置為FILES。例如:

bootstrap.yml

spring:
  cloud:
    consul:
      config:
        format: FILES

給定/config中的以下密鑰,development配置文件和應用程序名稱為foo:

gitignore
application.yml
bar.properties
foo-development.properties
foo-production.yml
foo.properties
master.ref

將創建以下屬性來源:

config/foo-development.properties
config/foo.properties
config/application.yml

每個鍵的值需要是一個格式正確的YAML或Properties文件。

快速失敗

在某些情況下(如本地開發或某些測試場景)可能會方便,如果不能配置領事,則不會失敗。在bootstrap.yml中設置spring.cloud.consul.config.failFast=false將導致配置模塊記錄一個警告而不是拋出異常。這將允許應用程序繼續正常啟動。

Spring Cloud Consul—git2consul與配置