先解释下为何忽然断更半个月: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/文档