新建乙個模組作為配置中心。具體步驟如下:
1. 新建乙個模組
2. 加入依賴:
《主要是這個依賴》3.新增配置(配置中心也算是乙個服務模組,也得註冊到註冊中心上)org.springframework.cloud
spring-cloud-config-server
org.springframework.cloud
spring-cloud-starter-netflix-eureka-client
org.springframework.boot
spring-boot-starter-actuator
org.springframework.boot
spring-boot-devtools
runtime
true
cn.aib.springcloud
springclud-api-common
1.0-snapshot
org.springframework.boot
spring-boot-starter-test
test
//這個是配置檔案所在的倉庫的位址
search-paths:
- springcloud-config //這個是倉庫名
label: master //哪個分支,雖然github上面已經是main分支了,目前master還能配置
4.主啟動
@enableconfigserver
public
class
public
static
void
main(string args)
}5.測試。可以訪問config暴露出來的介面來獲取配置資訊,比如:http://localhost:3344/main/config-test.yml;之前是master,現在訪問必須是main了
至於這個訪問的uri規則,如下:
SpringCloud config 配置中心
spring cloud config為服務端和客戶端提供了分布式系統的外部化配置支援。配置伺服器為各應用的所有環境提供了乙個中心化的外部配置。一般外部配置檔案存在github.com上。下面是config的 實現 新建配置中心模組 配置pom org.springframework.cloud s...
Spring Cloud Config 配置中心
比如使用 yml 或者 properties yml testconfig testvalueproperties testconfig testvalue伺服器配置檔案 呼叫config server url後返回的json資料 紅框中為配置正確後解析樣子 否則無法解析!在分布式系統中,由於服務數...
Spring Cloud Config 配置重新整理
客戶端進行重新整理操作。1 新增 actuator包,這樣 refresh url才處於可用狀態。org.springframework.boot spring boot starter actuator 2 手動測試時,關閉許可權認證,否則訪問時會出現無許可權。3 在controller上新增 r...