第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

跟我學(xué)Spring Cloud(Finchley版)-20-Spring Cloud Config-Git倉(cāng)庫(kù)配置詳解

標(biāo)簽:
Spring Cloud

跟我学Spring Cloud(Finchley版)-19-配置中心-Spring Cloud Config 一节中,已实现使用Git仓库作为Config Server的后端存储,本节详细探讨如何配置Git仓库。

一、占位符支持

Config Server的占位符支持{application}、{profile}和{label}。

示例:

server:
  port: 8080spring:
  application:
    name: microservice-config-server
  cloud:
    config:
      server:
        git:
          uri: https://git.oschina.net/itmuch/{application}
          username:
          password:

使用这种方式,即可轻松支持一个应用对应一个Git仓库。同理,也可支持一个profile对应一个Git仓库。

二、模式匹配

模式匹配指的是带有通配符的{application}/{profile}名称的列表。如果{application}/{profile}不匹配任何模式,它将会使用spring.cloud.config.server.git.uri 定义的URI。

spring:
  cloud:
    config:
      server:
        git:
          uri: https://github.com/spring-cloud-samples/config-repo
          repos:
            simple: https://github.com/simple/config-repo
            special:
              pattern: special*/dev*,*special*/dev*
              uri: https://github.com/special/config-repo
            local:
              pattern: local*
              uri: file:/home/configsvc/config-repo

该例中,对于simple仓库,它只匹配所有配置文件中名为simple的应用程序,它的模式等同于simple/* 。local仓库则匹配所有配置文件中以local开头的所有应用程序的名称。

三、搜索目录

很多场景下,我们可能把配置文件放在了Git仓库子目录中,此时可以使用search-paths指定,search-path同样支持占位符。

spring:
  cloud:
    config:
      server:
        git:
          uri: http://git.oschina.net/itmuch/spring-cloud-config-repo
          search-paths: foo,bar*

这样,Config Server就会在Git仓库根目录、foo子目录、以及所有以bar开始的子目录中查找配置文件。

四、启动时加载配置文件

默认情况下,在配置被首次请求时,Config Server才会clone Git仓库。我们也可让Config Server在启动时就clone Git仓库,例如。

spring:
  cloud:
    config:
      server:
        git:
          uri: https://github.com/spring-cloud-samples/config-repo
          repos:
            team-a:
                pattern:  microservice-*                clone-on-start: true
                uri: http://git.oschina.net/itmuch/spring-cloud-config-repo

将属性spring.cloud.config.server.git.repos.*.clone-on-start 设为true,即可让Config Server启动时clone指定Git仓库。

当然,也可使用spring.cloud.config.server.git.clone-on-start = true 进行全局配置。

配置clone-on-start = true,可帮助Config Server启动时快速识别错误的配置源(例如无效的Git仓库)。

小技巧

将以下包的日志级别设为DEBUG,即可打印Config Server请求Git仓库的细节。我们可借助日志,更好地理解Config Server的Git仓库配置,同时,也便于我们快速定位问题。

logging:  level:    org.springframework.cloud: DEBUG
    org.springframework.boot: DEBUG




點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評(píng)論
  • 收藏
  • 共同學(xué)習(xí),寫下你的評(píng)論
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消