先解釋下為什么突然斷更半個月:
總之,2019開局很不順利……Anyway,今天開工,今天恢復更新。
依賴中有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
參考文檔:<http://www.itmuch.com/spring-cloud/spring-cloud-bus-auto-refresh-configuration/>
引入Cloud Bus后,就會多一個/actuator/bus-refresh
端點
<http://www.itmuch.com/spring-cloud/finchley-22/>
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。