spring cloud config配置

在本地啓動config,拉取的git的url與配置的不一樣?
解決: 查看配置中 basedir 需要配置本地環境支持的目錄, window 如 E:/config
spring - cloud -server 中配置 application.yml
spring:  
  cloud:
    config:
      server:
        git:
          uri:  http://git.xxx
          username: xxx
          password: xxx
          search-paths: /config/**   #如果目錄下還有區分目錄  就加上/**
          basedir:  F:\config-dev   # 一定要與當前系統的目錄結構保持一致
          default-label: dev   # 拉取的分支

config 客戶端配置

spring:
  cloud:
    config:
      discovery:
      profile: dev # 切換環境 如 product-dev, product-test, 默認是 product,如果不配置會使用application.yml中配置的spring.profiles.active 的環境
        service-id: config  # 註冊中心config的服務名
     
config-client中 spring.cloud.config.profile 如果不配置會使用application.yml中配置的spring.profiles.active 的環境
如果不配置spring.cloud.config.profile和spring.profiles.active 會默認取git中的 product.yml
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章