客户端进行刷新操作。

1、添加 actuator包,这样 /refresh url才处于可用状态。

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

  

2、手动测试时,关闭权限认证,否则访问时会出现无权限。

management:
security:
enabled: false

3、在controller上添加@RefreshScope注解,添加@RefreshScope类会在配置更改时特殊的处理。

  是否可用在 其他用到配置的的类上 未测试。

package com.thunisoft.thunisoftmicroservicetestconfig.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController; @RefreshScope
@RestController
public class DisplayConfigController { @Value("${profile}")
private String profile; @GetMapping("/")
public String showConfig() {
return this.profile;
}
}

4、刷新配置

D:\curl\AMD64>curl -X POST http://localhost:7989/refresh
["config.client.version","profile"]
D:\curl\AMD64>

  

之后配置会更新为最新值。

相关阅读:

Spring Cloud Config 配置中心 自动加解密功能 JCE方式

Spring Cloud Config 配置中心 自动加解密功能 jasypt方式

最新文章

  1. HTML5本地存储
  2. js动画
  3. 【JavaWeb】MVC案例之新闻列表
  4. SSH/SSL 源码编译安装简易操作说明
  5. Mahout源码分析之 -- QR矩阵分解
  6. Til the Cows Come Home
  7. 泛函编程(23)-泛函数据类型-Monad
  8. node的passport.js验证
  9. 复利计算--4.0 单元测试之JAVA版-软件工程
  10. hdu 5207
  11. iOS 使用compare 进行对比
  12. (5)RARP:逆地址解析协议
  13. HDU4632:Palindrome subsequence(区间DP)
  14. Android 在子线程中更新UI
  15. iOS多线程的初步研究
  16. 数据结构之R进制转换
  17. 深入理解Spring Redis的使用 (九)、通过Redis 实现 分布式锁 的 BUG,以及和数据库加锁的性能测试
  18. 一篇博客带你入门Flask
  19. 初次安装Ubuntu后的若干配置步骤
  20. log4net配置文件

热门文章

  1. Windows Mobile入门
  2. MySql(十八):MySql架构设计——高可用设计之 MySQL 监控
  3. js评价五星
  4. [javase学习笔记]-8.6 静态的内存载入
  5. Linux重启命令与如何重启网络?
  6. EMIT 动态创建类型
  7. 【iOS XMPP】使用XMPPFramewok(五):好友列表
  8. GitBash: 右键添加 Git Bash Here 菜单
  9. VS2015终极卸载方法
  10. 手动分析linux是否中毒的几个考虑点