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

}

 

相关文章:

  • 2021-04-13
  • 2021-06-25
  • 2021-09-28
  • 2021-08-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-04
猜你喜欢
  • 2022-12-23
  • 2021-11-11
  • 2021-05-03
  • 2021-09-09
  • 2021-05-10
  • 2021-06-13
相关资源
相似解决方案