啟動服務(wù)器:
$ cd spring-cloud-config-server$ ../mvnw spring-boot:run
該服務(wù)器是一個(gè)Spring Boot應(yīng)用程序,所以您可以從IDE運(yùn)行它,而不是喜歡(主類是ConfigServerApplication)。然后嘗試一個(gè)客戶端:
$ curllocalhost: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"}}? ]}
定位資源的默認(rèn)策略是克隆一個(gè)git倉庫(在spring.cloud.config.server.git.uri),并使用它來初始化一個(gè)迷你SpringApplication。小應(yīng)用程序的Environment用于枚舉屬性源并通過JSON端點(diǎn)發(fā)布。
HTTP服務(wù)具有以下格式的資源:
/{application}/{profile}[/{label}]?
/{application}-{profile}.yml?
/{label}/{application}-{profile}.yml?
/{application}-{profile}.properties?
/{label}/{application}-{profile}.properties?
其中“應(yīng)用程序”作為SpringApplication中的spring.config.name注入(即常規(guī)的Spring Boot應(yīng)用程序中通常是“應(yīng)用程序”),“配置文件”是活動配置文件(或逗號分隔列表的屬性),“l(fā)abel”是可選的git標(biāo)簽(默認(rèn)為“master”)。
Spring Cloud Config服務(wù)器從git存儲庫(必須提供)為遠(yuǎn)程客戶端提供配置
spring:cloud:config:server:git:uri:https://github.com/spring-cloud-samples/config-repo?
完整項(xiàng)目的源碼來源 技術(shù)支持求求1791743380