当前位置: 首页 > 知识库问答 >
问题:

在Spring云配置客户端中启用/总线/刷新endpoint

欧镜
2023-03-14

我的Spring云配置客户端依赖于Spring。云起动机。公共汽车amqp,但它仍然没有启用总线/刷新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")

我在配置客户端应用程序中有这些依赖项,但仍然没有启用总线/刷新、总线/环境。

请让我知道我的客户申请中缺少什么。

注:

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

我尝试在应用程序中设置这些指标。yml或应用程序。属性,因为这些属性由总线自动配置用来启用endpoint。

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

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

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

并观察到,在Spring Boot启动期间,没有启用endpoint。

共有3个答案

干浩阔
2023-03-14

我面临着完全相同的问题。我的观察结果如下:我纠正了这一点,RabbitMQ/AMQP maven依赖性是我的主要问题。

我的微服务

我的pom.xml如下:

        <!-- Use this! I replaced this maven dep. for following one -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-bus-amqp</artifactId>
        </dependency>

        <!-- I was using this maven dep. initially which when replaced by the above solved my issue. Avoid using this for now.
        <dependency>
            <groupId>org.springframework.amqp</groupId>
            <artifactId>spring-rabbit</artifactId>
        </dependency>
        -->

我的application.properties/bootstrap.properties如下:

management.endpoints.web.exposure.include=bus-refresh

此URL适用于我:http://localhost:8080/actuator/bus-刷新与否:/bus/refresh或/bus/env

1) 您需要在micro服务模块和springCloudConfigServer模块中都有spring boot starter执行器和spring cloud starter总线amqp maven依赖项。

2) 在我的微服务模块中,当我使用spring-rabbit-maven-dep时。

3)然后,我更新了我的微服务pom文件从spring-Rabbit到spring-cloud-starter-bus-amqp,

希望这对你有帮助。如果没有,您可以参考此链接

家浩瀚
2023-03-14

使用我截至2018年4月12日的调查结果更新此问题

/执行器/总线刷新是从配置服务器开始的方式。

在您的application.properties:

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

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

通知所有注册的客户端更新其配置。

我发现的大多数现有文章都没有这一点,但我设法在这里根据反复试验和一些解决方案找到了最简单的一篇。

曹臻
2023-03-14

您是否将客户端的url映射到总线/刷新?我相信默认情况下它会映射到刷新。

您也可以尝试在以下位置向客户端应用发送POST请求:

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

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

顺便说一句,我在上发布了一篇详细的演示文章:使用Spring Cloud Config Server、Spring Cloud Bus、RabbitMQ和Git的可刷新配置,这可能会帮助您作为一个起点。

 类似资料:
  • 我在Kafka的spring云总线上配置了一个spring云配置服务器。我正在使用Edgware。随boot 1.5.9一起发布。当我向endpoint/总线/刷新发送POST请求时,destination=clientId:dev:*在主体中通过POSTMAN to config server,所有客户端都会刷新其bean,即使其clientId与destination字段中的值不匹配。 以下是

  • 我有一个客户端,它监听配置服务器。配置服务器指向github。使用localhost时一切正常。然而,当我将应用程序部署到Kubernetes时,用于刷新属性的客户端endpoint无法正常工作。 endpoint(后):http://config-client.sbx.com/actuator/refresh 这将在Postman“[]”上返回一个空响应,响应代码为200 OK。我能够看到配置服

  • 我有一个配置服务器,一个Spring Boot2.3.1应用程序连接到该服务器,为正确的配置文件加载配置属性。 配置服务器使用git获取每个应用程序和配置文件的配置文件。 这工作正常,当Spring Boot应用程序启动时,它将从配置服务器加载属性的正确值。 当我在配置文件中更新一个值并将其推送到git中,然后对Spring Boot应用程序的endpoint执行操作时,我会看到返回一个json,

  • 我正在使用Spring cloud config Finchley。M8版本,带Spring防尘套2.0.0。释放我注意到/总线/刷新已更改为/总线刷新。但每当我使用post http请求点击url时,它都不起作用。下面是应用程序的一个片段。属性: 此外,我扩展了WebSecurityConfigrerAdapter以添加以下代码片段: 这是我尝试测试的url: 然后我收到了以下错误消息 另外,这

  • 我有一个短期任务,客户端到spring云配置。(依赖于spring cloud starter配置或spring cloud配置客户端)。 正如我提到的,这是一个短暂的任务,它启动、从服务器加载配置、进行一些处理并关闭。 问题是spring-cloud d-config-Client启动Web服务器(tomcat),这是冗余的-我不想在我的客户端应用程序/任务上启动Web服务器。 我知道这个Web

  • 据我所知,当Spring Cloud Config Server配置更改时,可以通过Spring Cloud Bus在微服务之间传播刷新事件。然后,这会触发通知的微服务从Spring Cloud Config Server中提取最新配置。 这种方法的扩展性好吗?我的意思是,我们可以有1000个微服务实例,如果一些全局配置发生变化,那么所有这1000个微服务都会在同一时刻尝试从配置服务器获取配置。这