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

}
原文地址:https://www.cnblogs.com/lzj123/p/9724499.html