Spring cloud之/bus/refresh接口无用


在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;
    }

}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM