springCloud-8.統一配置中心Config Server

簡介git

Config Server:爲了方便管理開發環境,測試環境,生產環境配置spring

1.建立Config Server新項目app

2.Config Server會從Git上拉取配置,咱們先去Git上新建個文件,注意建私有項目測試

拷貝以前eureka-client項目配置url

改完提交3d

 

3.Enabled的套路直接去啓動文件先加上Enabled的啓動配置code

4.修改項目配置文件server

spring:
  application:
    name: config
  cloud:
    config:
      server:
        git:
          uri:  #文件git地址
          username: #git用戶名
          password: #git密碼
eureka:
  client:
    service-url:
      defaultZone: http://localhost:8001/eureka/
server:
  port: 8082

5.啓動項目測試blog

訪問路徑的命名規則:開發

1./{name}-{profiles}.yml

2./{label}/{name}-{profiles}.yml

name  服務名

profiles  環境

label    分支(若是不加默認使用master分支)

 

再master新搞個文件測試哈第1種規則

    訪問http://localhost:8082/customer-dev.yml  

經過這個咱們就能夠把各個環境的配置進行隔離

 

再新搞個分支測試哈第2種規則

訪問http://localhost:8082/release/customer-dev.yml

相關文章
相關標籤/搜索