Spring Cloud之Finchley版学习(二十二)-Spring Cloud Config-配置动态刷新

栏目: Java · 发布时间: 6年前

内容简介:待刷新的配置属性所在的类上添加了这样,修改参考文档:

配置刷新三要素

spring-boot-starter-actuator
/actuator/refresh
management:
  endpoints:
    web:
      exposure:
        include: refresh

待刷新的配置属性所在的类上添加了 @RefreshScope 注解 ,例如:

@RestController
@RefreshScope
public class ConfigClientController {
  @Value("${profile}")
  private String profile;

  @GetMapping("/profile")
  public String hello() {
    return this.profile;
  }
}

这样,修改 profile 配置后,只需向应用的 /actuator/refresh 端点发送POST请求,即可刷新该属性。例如:

curl -X POST http://localhost:8081/actuator/refresh

自动刷新、批量刷新-Spring Cloud Bus

参考文档: http://www.itmuch.com/spring-cloud/spring-cloud-bus-auto-refresh-configuration/

引入Cloud Bus后,就会多一个 /actuator/bus-refresh 端点。

本文链接跟我学Spring Cloud(Finchley版)-22-Spring Cloud Config-配置动态刷新


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Flash PHP实用开发技术

Flash PHP实用开发技术

Steve Webster著、王黎译 / 王黎 / 清华大学出版社 / 2002-3 / 39.00元

本书将介绍服务器端脚本所提供的各种可能的操作方案,帮助读者掌握设计数据库集成程序和高端应用程序的知识。一起来看看 《Flash PHP实用开发技术》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

随机密码生成器
随机密码生成器

多种字符组合密码

MD5 加密
MD5 加密

MD5 加密工具