spring cloud-BUS总线配置

 

目录

配置中心

pom

yml

客户端

pom

yml


bus一般配合config使用,以下都是在config基础上添加,pom中bus配合actuator使用

配置中心

pom

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-bus-amqp</artifactId>
        </dependency>

yml

server:
  port: 3344
spring:
  application:
    name: cloud-config-center
  cloud:
    config:
      server:
        git:
          uri: https://github.com/用户名/springcloud-config.git #github仓库名字,对应哪个地址
          search-paths: #搜索目录
            - springcloud-config  #哪个仓库
          force-pull: true
          username: 用户
          password: 密码
      label: mian   #哪个分支
  rabbitmq:
    host: localhost
    port: 5672
    username: guest
    password: guest
eureka:
  client:
    service-url:
      defaultZone:  http://localhost:7001/eureka
management: #暴露监控端点
  endpoints:
    web:
      exposure:
        include: "bus-refresh"

客户端

pom

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-bus-amqp</artifactId>
        </dependency>

yml

server:
  port: 3355
spring:
  application:
    name: config-client
  cloud:
    config: #客户端配置
      label: master #分支名称
      name: config  #配置文件名称
      profile: dev  #读取的后缀的名称 结合起来就是读取 master/config-dev.yml的配置文件
      uri: http://localhost:3344  #配置中心地址

  rabbitmq:
    host: localhost
    port: 5672
    username: guest
    password: guest
eureka:
  client:
    service-url:
      defaultZone:  http://localhost:7001/eureka
management: #暴露监控端点
  endpoints:
    web:
      exposure:
        include: "*"

修改github中的配置文件后执行

1、全部通知

curl -X POST "http://localhost:3344/actuator/bus-refresh"

2、指定客户端通知

curl -X POST "http://localhost:3344/actuator/bus-refresh/config-client:3355"

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值