【问题标题】:Spring Cloud Consul /refresh endpoint missing缺少 Spring Cloud Consul /refresh 端点
【发布时间】:2016-07-20 04:12:33
【问题描述】:

我正在使用 Spring Cloud Consul 与 Consul 进行分布式配置,一切正常。当前所有配置都在应用程序启动时从 Consul 服务器成功读取。但是当 Consul 上的某些数据发生更改时,我无法为我的应用重新加载此配置,因为没有 /refresh 端点。但是here 说“向 /refresh 发送 HTTP POST 将导致重新加载配置。”据我了解,它应该类似于 Spring Cloud Config Client,但事实并非如此。我错过了什么?

【问题讨论】:

    标签: java spring spring-boot spring-cloud consul


    【解决方案1】:

    您需要包含弹簧靴执行器

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
    

    【讨论】:

      【解决方案2】:

      或者在你的bean上添加@RefreshScope,例如

      @Component
      @RefreshScope
      public class MyConsulConfig  {
      
      @Value("${consul.base.url}")
      private String baseUrl;
      }
      

      【讨论】:

      • true..但它会刷新值而不需要调用 /refresh?
      • Consul 有一个配置监视,当值更改时会刷新
      猜你喜欢
      • 1970-01-01
      • 2017-10-12
      • 2020-05-18
      • 2016-02-18
      • 2015-11-04
      • 2018-12-23
      • 2022-10-22
      • 1970-01-01
      • 2019-06-24
      相关资源
      最近更新 更多