之前项目升级sprint-cloud,导致原本工作正常的刷新配置不work了。
下面是我的解决的办法:
/bus/refresh
management.endpoints.web.exposure.include=refresh,health,info,bus-refresh
management.endpoints.bus-refresh.enabled=true
加完这两个properties之后,可以通过postman测试,http://host:port/actuator/bus-refresh 是可以刷新config-server
还有一种,则是在通过代码发起http请求刷新config-server中心
一开始,我直接使用rest template
restTemplate.exchange(BUS_CONFIG_URL, HttpMethod.POST, null, Void.class);
尝试运行代码,后台还是会报405 , method not allow
然后经过我的研究发现,你必须要为请求设置content-type application/json
所以,我把我的代码改成了
MultiValueMap<String, Object> parts = new LinkedMultiValueMap<>();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity httpEntity = new HttpEntity(parts);
restTemplate.exchange(BUS_CONF