zoukankan      html  css  js  c++  java
  • Spring Cloud Bus 自动更新配置

    ---恢复内容开始---

    Spring Cloud Config 结合 Spring Cloud bus 实现 git 仓库提交配置文件 触发消息队列 应用自动更新配置

    1. config 服务端 添加依赖  

        

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

      在配置中加入 

    management:
      endpoints:
        web:
          exposure:
            include: bus-refresh

            暴露bus-refresh 接口  * 暴露所有接口

    2. config 客户端 加入依赖 

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

    在需要读取配置的地方加入  @RefreshScope 注解   通过 @Value 或 @ConfigurationProperties 读取 配置

    启动项目  

     打开RabbitMQ  确认加入队列成功

       以 gitee为例   

       

                修改后提交

                访问配置中心  

                

            已更改  但是应用中没有更新 ,现在请求 

              http://localhost:8888/actuator/bus-refresh 

            可以看到有消息传过来 

             

             在请求应用  

      获取到了最新值

  • 相关阅读:
    重构DataGridView的方法
    Js中得到radiobuttonlist 和CheckBoxList 的值
    01、Android系统系统架构
    10、JavaEEDBUtils工具类
    07、JavaEEJSP自定义标签
    11、JavaEEFilter
    08、JavaEEMysql基础
    09、JavaEEJDBC
    简单易忘哈哈(sql语句中的空格问题)
    定义Connection对象con的好处
  • 原文地址:https://www.cnblogs.com/qin1993/p/11578671.html
Copyright © 2011-2022 走看看