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

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

Spring Cloud 配置中心高可用搭建

標(biāo)簽:
Spring Cloud

本文通过config server连接git仓库来实现配置中心,除了git还可以使用svn或者系统本地目录都行。

引入依赖

<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-config-server</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-eureka</artifactId>
    </dependency></dependencies>

spring-cloud-config-server这个就是配置中心server的依赖。

配置中心做到高可用本身也需要向注册中心注册自己的实例,所以需求引用spring-cloud-starter-eureka依赖。

添加启动类,开启Config Server功能

@EnableDiscoveryClient@EnableConfigServer@SpringBootApplicationpublic class ConfigApplication {    public static void main(String[] args) {
        SpringApplication.run(ConfigApplication.class, args);
    }

}

@EnableConfigServer:即开启配置服务器的功能。

@EnableDiscoveryClient:开启自动注册客户端,默认情况下,ServiceRegistry实现将自动注册正在运行的服务。如注册中心使用是Eureka,这里也可以使用的@EnableEurekaClient注解。

添加Config配置

spring: 
  application:
    name: config-center  profiles:
    active: config-center1  cloud: 
    config:
      server:
        git:
          uri: ${git.uri}          searchPaths: ${git.searchPaths}          username: ${git.username}          password: ${git.password}          basedir: ${git.basedir}
          clone-on-start: true
          force-pull: true
          eureka:
  instance: 
    prefer-ip-address: true  
    instance-id: ${spring.cloud.client.ipAddress}:${server.port}
    lease-expiration-duration-in-seconds: ${lease-expiration-duration-in-seconds}
    lease-renewal-interval-in-seconds: ${lease-renewal-interval-in-seconds}  client:
    serviceUrl:
      defaultZone: ${register-center.urls}
    
---spring:
  profiles: config-center1  
server: 
  port: ${config-center1.server.port}

---spring: 
  profiles: config-center2  
server: 
  port: ${config-center2.server.port}

这里配置了两台Config Server,都注册到了两台注册中心上。

Maven filter配置

#gitgit.uri=http://gitlab.example.com/test/config.git
git.username=root
git.password=root
git.searchPaths=config-center
git.basedir=f:/config/config-center/git

Spring Cloud Git配置详解

spring.cloud.config.server.git.uri:git仓库地址。

spring.cloud.config.server.git.searchPaths:git仓库搜索目录。

spring.cloud.config.server.git.username:连接git的用户名。

spring.cloud.config.server.git.password:连接git的用户名密码。

spring.cloud.config.server.git.basedir:配置中心在本地缓存配置的目录。

spring.cloud.config.server.git.clone-on-start:配置为true表示启动时就克隆配置缓存到本地。

spring.cloud.config.server.git.force-pull:配置为true表示如果本地副本是脏的,将使Spring Cloud Config Server强制从远程存储库拉取配置。

启动配置中心

分别启动以下配置中心,使用不同的Profile指定端口。

spring-boot:run -Drun.profiles=config-center1 -P dev
spring-boot:run -Drun.profiles=config-center2 -P dev



作者:Java技术栈
链接:https://www.jianshu.com/p/7c29e2cf6ec6


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

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

評(píng)論

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

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

100積分直接送

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

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

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

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

幫助反饋 APP下載

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

公眾號(hào)

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

舉報(bào)

0/150
提交
取消