###1.為什么要使用config
- 集中管理
- 不通環境不通配置
- 運行期間動態調整配置
- 自動刷新 ###2.用法入門
- 導入pom
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-config-server</artifactId></dependency>
復制代碼
- 啟動類添加注解
@EnableConfigServer
- 修改application.yml
spring:cloud:config:server:git:uri: https://github.com/jiaofanting/spring-cloud-config-repo/
server:port: 8080復制代碼
docker默認端口?這個uri是我git目錄放的一個application.yml 路徑,打開是404,因為它不是一個有效的鏈接,它只是說明了 application.yml文件放在哪里。 4. 看官方文檔說明
The HTTP service has resources in the form:/{application}/{profile}[/{label}]
/{application}-{profile}.yml
/{label}/{application}-{profile}.yml
/{application}-{profile}.properties
/{label}/{application}-{profile}.propertieswhere the "application" is injected as the spring.config.name in the SpringApplication (i.e. what is normally "application" in a regular Spring Boot app), "profile" is an active profile (or comma-separated list of properties), and "label" is an optional git label (**defaults to "master".**)
復制代碼
截圖更清晰
注意中間有個- ,對照文檔看效果