Spring Cloud之Finchley版學習(二十二)-Spring Cloud Config-配置動態重新整理
配置重新整理三要素
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-配置動態重新整理