Spring Cloud Config-快速開始

啓動服務器:

$ cd spring-cloud-config-server  
$ ../mvnw spring-boot:run  

該服務器是一個Spring Boot應用程序,所以您可以從IDE運行它,而不是喜歡(主類是ConfigServerApplication)。然後嘗試一個客戶端:

$ curl localhost:8888/foo/development  
{"name":"development","label":"master","propertySources":[  
  {"name":"https://github.com/scratches/config-repo/foo-development.properties","source":{"bar":"spam"}},  
  {"name":"https://github.com/scratches/config-repo/foo.properties","source":{"foo":"bar"}}  
]}  

定位資源的默認策略是克隆一個git倉庫(在spring.cloud.config.server.git.uri),並使用它來初始化一個迷你SpringApplication。小應用程序的Environment用於枚舉屬性源並通過JSON端點發布。

HTTP服務具有以下格式的資源:

/{application}/{profile}[/{label}]  
/{application}-{profile}.yml  
/{label}/{application}-{profile}.yml  
/{application}-{profile}.properties  
/{label}/{application}-{profile}.properties  

其中“應用程序”作爲SpringApplication中的spring.config.name注入(即常規的Spring Boot應用程序中通常是“應用程序”),“配置文件”是活動配置文件(或逗號分隔列表的屬性),“label”是可選的git標籤(默認爲“master”)。

Spring Cloud Config服務器從git存儲庫(必須提供)爲遠程客戶端提供配置

spring:  
  cloud:  
    config:  
      server:  
        git:  
          uri: https://github.com/spring-cloud-samples/config-repo  
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章