Spring Boot 的actuator提供了一个刷新端点/refresh,添加依赖spring-boot-starter-actuator,可用于配置的刷新;
1、添加依赖:
<!--springboot的一个监控actuator-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
2、在Controller上添加注解@RefreshScope,添加这个注解的类会在配置更新时得到特殊的处理;
3、打开web访问端点:management.endpoints.web.exposure.include=*
4、访问http://localhost:8080/actuator/refresh 进行手动刷新配置;
(Post访问)
这种方式的刷新,就是你对每个微服务分别进行刷新,也一个一个操作,如果你有80个微服务,那么就需要手动刷新这80个微服务;