跟我學習Spring Cloud Config - 快速開始

來源:互聯網
上載者:User

標籤:content   file   get   .com   sources   soft   lis   屬性   策略   

啟動伺服器:

$ 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
更多資料和源碼來源

跟我學習Spring Cloud Config - 快速開始

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.