1.前言
前文链接:Spring Cloud 学习——7. Spring Cloud Config
前一篇文章我们学习了通过 Spring Cloud Config + git 实现分布式系统的统一配置管理。但是在实际项目中,我们只是实现配置往往是不够的,我们经常会遇到需要在项目运行时修改配置的需求。接下来我们就学习一下,如何在 Spring Cloud Config 环境下动态地(不重启服务)修改配置。
我们分三步实现:
第一步: 手动动态刷新单个服务实例的配置;
第二步:手动动态刷新整个系统所有服务实例的配置;
第三步:自动动态刷新整个系统所有服务实例的配置;
2.第一步,实现手动动态刷新单个服务实例的配置
2.1.在 config-client 服务模块添加依赖(版本自选)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.2.4.RELEASE</version>
</dependency>