先解釋下爲何忽然斷更半個月:web
總之,2019開局很不順利……Anyway,今天開工,今天恢復更新。spring
依賴中有spring-boot-starter-actuator
app
添加以下配置,暴露/actuator/refresh
端點:curl
management: endpoints: web: exposure: include: refresh
待刷新的配置屬性所在的類上添加了@RefreshScope
註解 ,例如:spring-boot
@RestController @RefreshScope public class ConfigClientController { @Value("${profile}") private String profile; @GetMapping("/profile") public String hello() { return this.profile; } }
這樣,修改profile
配置後,只需嚮應用的/actuator/refresh
端點發送POST請求,便可刷新該屬性。例如:this
curl -X POST http://localhost:8081/actuator/refresh
參考文檔:http://www.itmuch.com/spring-cloud/spring-cloud-bus-auto-refresh-configuration/url
引入Cloud Bus後,就會多一個/actuator/bus-refresh
端點code
http://www.itmuch.com/spring-cloud/finchley-22/文檔