首页 文章

在Spring Cloud Config Client中启用/总线/刷新 endpoints

提问于
浏览
1

我的Spring Cloud Config Client依赖于 spring.cloud.starter.bus.amqp ,但它仍未启用 /bus/refresh endpoint

build.gradle    
compile("org.springframework.cloud:spring-cloud-starter-stream-rabbit:1.1.3.RELEASE")    
compile("org.springframework.cloud:spring-cloud-starter-bus-amqp:1.2.2.RELEASE")

我在配置客户端应用程序中有这些依赖项,但仍然没有启用 /bus/refresh/bus/env .

请告诉我在客户端应用程序中缺少的内容 .

Note:

spring.cloud.bus.refresh.enabled: true
spring.cloud.bus.env.enabled: true
endpoints.spring.cloud.bus.refresh.enabled: true
endpoints.spring.cloud.bus.env.enabled: true

我已尝试在 application.ymlapplication.properties 中设置这些指标,因为这些指标由 BusAutoConfiguration 使用,以启用 /bus/* endpoints .

@ConditionalOnProperty(value = "endpoints.spring.cloud.bus.refresh.enabled", matchIfMissing = true)

在我的Spring Cloud Config Server应用程序中,我已禁用这些 endpoints ,即设置为false

endpoints.spring.cloud.bus.refresh.enabled: false
endpoints.spring.cloud.bus.env.enabled: false

并观察到在Spring Boot启动期间 /bus/* endpoints 未启用 .

3 回答

  • 1

    您是否将客户的网址映射到 /bus/refresh ?我相信它默认映射到 /refresh .

    您还可以尝试向客户端应用发送POST请求:

    curl -X POST http://server:port/refresh
    

    我也相信你可能不需要 spring-cloud-starter-stream-rabbit 依赖,只需 spring-cloud-starter-bus-amqp .

    顺便说一句,我发表了一篇详细的文章,其中包含以下工作演示:Refreshable Configuration using Spring Cloud Config Server, Spring Cloud Bus, RabbitMQ and Git可能会帮助您作为起点 .

  • 2

    用我的发现更新此问题截至2018/04/12

    / actuator / bus-refresh是配置服务器的方法 .

    在您的application.properties中:

    spring.cloud.bus.enabled=true
    management.endpoints.web.exposure.include=bus-refresh
    

    示例:curl -X POST http://localhost:8080/actuator/bus-refresh

    发信号通知所有注册客户更新其配置 .

    我发现的大多数现有文章没有这个,但我设法找到了最简单的一个基于试验和错误以及解决方案的花絮 .

  • 0

    查看代码后,发现 spring.cloud.config.bus.enabled 设置为false或被覆盖 .

    我在Spring Boot的顶部使用了企业框架jar;在 bootstrap.ymlspring.cloud.config.bus.enabled 为真,但这被配置服务器属性文件覆盖,即git属性文件存储库的值为false,并给出了优先级 .

    localhost:<port>/env
    

    应显示来自不同来源的所有 property ;像配置服务器,application.yml作为服务jar的一部分 . 在一个获得偏好的人中 .

    "configService:github uri": { list of properties }
    "systemProperties": { list of properties }
    "applicationConfig: [classpath:/application.properties]": { list of properties }
    

    在 Spring 天 env 下面,正在使用rest资源来确保此属性的确切值 .

    localhost:<port>/env/spring.cloud.config.bus.enabled
    

相关问题