在Springboot2.0之前是直接通路http://localhost:8888/actuator/bus/refresh去通知配置伺服器分發消息的,而到了Springboot 2.0之後Config用戶端自動重新整理時沒有/bus/refresh端點,是以需要如下配置
1. 在配置服務端和用戶端配置檔案中都加上如下配置
management.endpoints.web.exposure.include= bus-refresh
2. 在用戶端使用配置的類加上@RefreshScope注解
@RestController
@RefreshScope
public class TestController {
@Value("${name}")
private String name;
@GetMapping(value = "getGitConfig")
public String getGitConfig(){
return name;
}
}