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-配置动态刷新


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

查看所有标签

猜你喜欢:

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

The Master Switch

The Master Switch

Tim Wu / Knopf / 2010-11-2 / USD 27.95

In this age of an open Internet, it is easy to forget that every American information industry, beginning with the telephone, has eventually been taken captive by some ruthless monopoly or cartel. Wit......一起来看看 《The Master Switch》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

在线进制转换器
在线进制转换器

各进制数互转换器

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

多种字符组合密码