客户端进行刷新操作。

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方式

Spring Cloud Config 配置刷新的更多相关文章

  1. spring cloud config配置记录

    1. spring cloud config配置记录 1.1. pom <!-- 分布式配置中心 --> <dependency> <groupId>org.spr ...

  2. 跟我学SpringCloud | 第七篇:Spring Cloud Config 配置中心高可用和refresh

    SpringCloud系列教程 | 第七篇:Spring Cloud Config 配置中心高可用和refresh Springboot: 2.1.6.RELEASE SpringCloud: Gre ...

  3. 微服务SpringCloud之Spring Cloud Config配置中心Git

    微服务以单个接口为颗粒度,一个接口可能就是一个项目,如果每个项目都包含一个配置文件,一个系统可能有几十或上百个小项目组成,那配置文件也会有好多,对后续修改维护也是比较麻烦,就和前面的服务注册一样,服务 ...

  4. 微服务SpringCloud之Spring Cloud Config配置中心服务化

    在前面两篇Spring Cloud Config配置中心的博客中都是需要指定配置服务的地址url:spring.cloud.config.uri,客户端都是直接调用配置中心的server端来获取配置文 ...

  5. spring cloud --- config 配置中心 [本地、git获取配置文件]

    spring boot      1.5.9.RELEASE spring cloud    Dalston.SR1 1.前言 spring cloud config 配置中心是什么? 为了统一管理配 ...

  6. Spring Cloud Config 自动刷新所有节点 架构改造

    详细参考:<Sprin Cloud 与 Docker 微服务架构实战>p162-9.9.4节 要做的改动是: 1.在spring cloud config server 服务端加入 spr ...

  7. Spring Cloud Config 自动刷新所有节点

    全局刷新 详细参考:<Sprin Cloud 与 Docker 微服务架构实战>p160-9.9.2节 1.使用Spring Cloud Config 客户端时,可以使用 /refresh ...

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

    使用此种方式会存在一种问题:如果我配置了自动配置刷新,则刷新过后,加密过后的密文无法被解密.具体原因分析,看 SpringCloud 详解配置刷新的原理 使用  jasypt-spring-boot- ...

  9. SpringCloud学习笔记(7):使用Spring Cloud Config配置中心

    简介 Spring Cloud Config为分布式系统中的外部化配置提供了服务器端和客户端支持,服务器端统一管理所有配置文件,客户端在启动时从服务端获取配置信息.服务器端有多种配置方式,如将配置文件 ...

随机推荐

  1. 用python参加Kaggle的经验总结【转】

    用python参加Kaggle的经验总结 转载自:http://www.jianshu.com/p/32def2294ae6,作者 JxKing    最近挤出时间,用python在kaggle上试了 ...

  2. Hive 打开调试模式

    编程过程中发现错误,无法看到具体的错误信息,网上搜了下,按照下面的方法启动Hive Shell就可以打开调试(注意:此方法只对本次回话有效): hive --hiveconf hive.root.lo ...

  3. 【转】在 Windows 10 下,配置 Kinect v2 可用于 Windows Hello 验证身份

    先要修改下注册表HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DriverFlighting\Partner如果没有这个文件夹就创建一个吧 然后创建一个字符串类型的变量T ...

  4. tomcat启动时出现了Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]等错误

    tomcat 启动时报错:Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]等错误 解决办法: 是 ...

  5. angular学习笔记(三十)-指令(7)-compile和link(2)

    继续上一篇:angular学习笔记(三十)-指令(7)-compile和link(1) 上一篇讲了compile函数的基本概念,接下来详细讲解compile和link的执行顺序. 看一段三个指令嵌套的 ...

  6. adb常用命令教程

    1.Android Debug Bridge - adb常用命令 1.1简介 Android Debug Bridge,我们一般简称为adb,主要存放在sdk安装目录下的platform-tools文 ...

  7. [Windows Azure] Load Testing in Windows Azure

    The primary goal of a load test is to simulate many users accessing a web application at the same ti ...

  8. git(8):常用命令

    Git常用操作命令收集: 1) 远程仓库相关命令 检出仓库:$ git clone git://github.com/jquery/jquery.git 查看远程仓库:$ git remote -v ...

  9. 如何让 zend studio 10 识别 Phalcon语法并且进行语法提示

    让 zend studio 10 识别 Phalcon语法并且进行语法提示 https://github.com/rogerthomas84/PhalconPHPDoc 下载解压后,把里面 phalc ...

  10. 根据ip查询经纬度的接口

    http://ip-api.com/json/ 直接访问,结果如下 // 20180804140751 // http://ip-api.com/json/ { "as": &qu ...