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

Spring Cloud Config Spring Cloud Bus RabbitMQ-不使用本地Git存储库自动刷新客户端

王刚毅
2023-03-14

我有一些应用程序从Spring Cloud Config Server(Brixton. RELEASE)获取其配置,并希望启用其属性的自动刷新。我已经按照Spring Cloud Config留档来配置服务器和客户端应用程序,但是在本地html" target="_blank">git文件上进行更改时不会发生任何事情。

默认配置还检测本地git存储库中的文件系统更改(在这种情况下不使用webhook,但一旦编辑配置文件,就会广播刷新)。

有人能指出可能出了什么问题或者在Spring Cloud的代码中调试到哪里来检查它吗?

Spring云服务器配置:

server:
  port: 8888

info:
  description: Spring Cloud Config Server

spring:
  application:
    name: config-server
  cloud:
    config:
      server:
        git:
          uri: file:///C:/Users/myuser/git/config-dev/

Spring Cloud Serverpom.xml

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-config-server</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-bus-amqp</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-config-monitor</artifactId>
    </dependency>

    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.1.0.Final</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
    </dependency>

Spring Cloud配置启动日志:

o.s.i.monitor.IntegrationMBeanExporter   : Registering MessageChannel springCloudBusInput
o.s.i.monitor.IntegrationMBeanExporter   : Located managed bean 'org.springframework.integration:type=MessageChannel,name=springCloudBusInput': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=springCloudBusInput]
o.s.i.monitor.IntegrationMBeanExporter   : Registering MessageChannel springCloudBusOutput
o.s.i.monitor.IntegrationMBeanExporter   : Located managed bean 'org.springframework.integration:type=MessageChannel,name=springCloudBusOutput': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=springCloudBusOutput]
o.s.i.monitor.IntegrationMBeanExporter   : Registering MessageChannel errorChannel
o.s.i.monitor.IntegrationMBeanExporter   : Located managed bean 'org.springframework.integration:type=MessageChannel,name=errorChannel': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=errorChannel]
o.s.i.monitor.IntegrationMBeanExporter   : Registering MessageChannel nullChannel
o.s.i.monitor.IntegrationMBeanExporter   : Located managed bean 'org.springframework.integration:type=MessageChannel,name=nullChannel': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=nullChannel]
o.s.i.monitor.IntegrationMBeanExporter   : Located managed bean 'org.springframework.integration:type=MessageHandler,name=errorLogger,bean=internal': registering with JMX server as MBean [org.springframework.integration:type=MessageHandler,name=errorLogger,bean=internal]
o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase -2147482648
o.s.c.s.binding.BindableProxyFactory     : Binding outputs for :interface org.springframework.cloud.bus.SpringCloudBusClient
o.s.c.s.binding.BindableProxyFactory     : Binding :interface org.springframework.cloud.bus.SpringCloudBusClient:springCloudBusOutput
s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@707ca986: startup date [Fri May 13 10:03:10 CEST 2016]; root of context hierarchy
trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$73faa1d3] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
e.m.a.config.ConfigServerApplication     : No active profile set, falling back to default profiles: default
s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@1ca610a0: startup date [Fri May 13 10:03:11 CEST 2016]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@294a6b8e
o.s.c.support.GenericApplicationContext  : Refreshing org.springframework.context.support.GenericApplicationContext@6048e26a: startup date [Fri May 13 10:03:11 CEST 2016]; root of context hierarchy
e.m.a.config.ConfigServerApplication     : Started ConfigServerApplication in 2.907 seconds (JVM running for 12.366)
o.s.a.r.c.CachingConnectionFactory       : Created new connection: SimpleConnection@7bbcf6f0 [delegate=amqp://guest@127.0.0.1:5672/]
o.s.i.endpoint.EventDrivenConsumer       : Adding {message-handler:outbound.springCloudBus} as a subscriber to the 'springCloudBusOutput' channel
o.s.integration.channel.DirectChannel    : Channel 'config-server:8888.springCloudBusOutput' has 1 subscriber(s).
o.s.i.endpoint.EventDrivenConsumer       : started outbound.springCloudBus
o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase -2147482648
o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 0
o.s.i.endpoint.EventDrivenConsumer       : Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
o.s.i.channel.PublishSubscribeChannel    : Channel 'config-server:8888.errorChannel' has 1 subscriber(s).
o.s.i.endpoint.EventDrivenConsumer       : started _org.springframework.integration.errorLogger
o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 2147482647
o.s.c.s.binding.BindableProxyFactory     : Binding inputs for :interface org.springframework.cloud.bus.SpringCloudBusClient
o.s.c.s.binding.BindableProxyFactory     : Binding :interface org.springframework.cloud.bus.SpringCloudBusClient:springCloudBusInput
o.s.c.s.b.r.RabbitMessageChannelBinder   : declaring queue for inbound: springCloudBus.anonymous.t4cuHSE6RfKRYvPvrgfbUg, bound to: springCloudBus
o.s.integration.channel.DirectChannel    : Channel 'springCloudBus.anonymous.t4cuHSE6RfKRYvPvrgfbUg.bridge' has 1 subscriber(s).
o.s.i.a.i.AmqpInboundChannelAdapter      : started inbound.springCloudBus.anonymous.t4cuHSE6RfKRYvPvrgfbUg

客户端应用程序pom。xml:

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-config</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-bus-amqp</artifactId>
    </dependency>

    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.1.0.Final</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
    </dependency>

客户端应用程序配置:

spring:
  application:
    name: app
  cloud:
    config:
      uri: http://localhost:8888

客户端应用程序启动日志:

o.s.b.a.e.m.EndpointHandlerMapping  INFO - Mapped "{[/bus/refresh],methods=[POST]}" onto public void org.springframework.cloud.bus.endpoint.RefreshBusEndpoint.refresh(java.lang.String)
...
o.s.i.m.IntegrationMBeanExporter  INFO - Registering beans for JMX exposure on startup
o.s.i.m.IntegrationMBeanExporter  INFO - Registering MessageChannel springCloudBusInput
o.s.i.m.IntegrationMBeanExporter  INFO - Located managed bean 'org.springframework.integration:type=MessageChannel,name=springCloudBusInput': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=springCloudBusInput]
o.s.i.m.IntegrationMBeanExporter  INFO - Registering MessageChannel springCloudBusOutput
o.s.i.m.IntegrationMBeanExporter  INFO - Located managed bean 'org.springframework.integration:type=MessageChannel,name=springCloudBusOutput': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=springCloudBusOutput]
o.s.i.m.IntegrationMBeanExporter  INFO - Registering MessageChannel nullChannel
o.s.i.m.IntegrationMBeanExporter  INFO - Located managed bean 'org.springframework.integration:type=MessageChannel,name=nullChannel': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=nullChannel]
o.s.i.m.IntegrationMBeanExporter  INFO - Registering MessageChannel errorChannel
o.s.i.m.IntegrationMBeanExporter  INFO - Located managed bean 'org.springframework.integration:type=MessageChannel,name=errorChannel': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=errorChannel]
o.s.i.m.IntegrationMBeanExporter  INFO - Located managed bean 'org.springframework.integration:type=MessageHandler,name=org.springframework.cloud.bus.BusAutoConfiguration.acceptRemote.serviceActivator,bean=endpoint': registering with JMX server as MBean [org.springframework.integration:type=MessageHandler,name=org.springframework.cloud.bus.BusAutoConfiguration.acceptRemote.serviceActivator,bean=endpoint]
o.s.i.m.IntegrationMBeanExporter  INFO - Located managed bean 'org.springframework.integration:type=MessageHandler,name=errorLogger,bean=internal': registering with JMX server as MBean [org.springframework.integration:type=MessageHandler,name=errorLogger,bean=internal]
o.s.b.a.e.j.EndpointMBeanExporter  INFO - Registering beans for JMX exposure on startup

共有3个答案

鄂坚
2023-03-14

您需要在pom中具有衰减依赖性。xml compile('org.springframework.cloud:spring-cloud-stream-binder-rabbit')-Gradle如果您在另一个系统中安装了rabbitmq,则需要在应用程序中指定主机文件。属性

Springrabbitmq。主机:{{主机名}}}

徐高韵
2023-03-14

您需要一个支持Spring云总线和RabbitMQ(或Kafka或Redis)的配置服务器。

...
<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-config-monitor</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
...

具有以下exchange的RabbitMQ:

名称:springCloudBus

类型:主题

耐用:真

自动删除:false

内部:false

配置服务器一旦从Github、Bitbucket或GitLab中的任何一个接收到推送事件,就会通过webhook向主题发送数据,以监视“rel=”nofollow noreferrer“>http://

以及具有Config和RabbitMQ库的客户端应用程序:

...
<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
...

已订阅上一个exchange以接收具有需要刷新的属性的邮件。

更多信息请访问我的博客:http://tech.asimio.net/2017/02/02/Refreshable-Configuration-using-Spring-Cloud-Config-Server-Spring-Cloud-Bus-RabbitMQ-and-Git.html简要说明配置服务器和客户端应用程序的配置、日志和完整源代码

颛孙俊
2023-03-14

请阅读本文档spring cloud config push notifications,不要忘记安装ngrock。此外,如果您只需要在git提交时刷新,那么您甚至不需要云总线项目,只需配置就足够了。希望这有帮助。

 类似资料:
  • 问题内容: 我的Maven配置有一个小问题。此处的所有其他问题和答案都不能解决我的问题,因此,我开始了一个新问题。 我的问题是,我的Maven没有使用本地存储库。它总是从远程存储库中获取工件。 当下载工件或构建项目时,它将安装在本地存储库中,因此路径正确。 问题是:当我构建一个SNAPSHOT项目时,它仅安装在本地存储库中(应该是这样,不想每次都将其发布在我的关系上)。当我在pom.xml中构建另

  • 我的Maven配置有一个小问题。这里所有其他的问题和答案都没有解决我的问题,所以我要开始一个新的问题。 我的问题是,我的Maven没有使用本地存储库。它总是从远程存储库中获取工件。 当下载工件或构建项目时,它被安装在本地存储库中,因此路径是正确的。 问题是:当我构建一个快照项目时,它只安装在本地存储库中(应该是这样的,不要每次都在我的nexus上发布)。当我构建另一个项目时,在pom.xml中有前

  • 问题内容: 我有一个客户端数据存储在localStorage中。出于安全原因,我要加密数据。有什么方法可以使用Angularjs加密/解密客户端数据(而非服务器数据)? 问题答案: 您可以使用cryptojs库对数据进行加密/解密。首先,您应该生成一些密钥以用于加密过程: 然后,您需要存储和声明数据的方法: 这里唯一的问题是秘密密钥存储在客户端,这是这种加密的一种破坏逻辑。

  • 我的SPA应用程序使用以下体系结构(来源): 这假设我的客户端应用程序知道刷新令牌,因为如果没有用户凭据(例如电子邮件/密码),我需要它来请求新的访问令牌。 我的问题:在客户端应用程序中,刷新令牌存储在哪里?关于这个话题有很多问题/答案,但是关于刷新标记,答案并不清楚。 访问令牌和刷新令牌不应存储在本地/会话存储器中,因为它们不是存放任何敏感数据的地方。因此,我会将访问令牌存储在一个cookie中

  • 问题内容: 我正在尝试使用minikube和kitematic在本地计算机上测试kubernetes。但是,kubernetes无法在我的本地存储库(ImagePullBackOff)中提取图像。 但是我没有/etc/init.d/docker,我认为是因为运动学?(我在OS X上) 编辑: 我安装了https://github.com/docker/docker- registry ,并且 我的

  • 问题内容: 我也是Jenkins和git的新手。我在创建了一个远程存储库并对其进行了本地复制。 然后,我想通过詹金斯链接它。我安装了git集成所需的插件,但是在配置新项目时,我不知道要在本地Repository URL中设置什么。有人可以帮我在哪里找到它吗? 问题答案: 在这种情况下,URL应该以文件协议开头,然后是存储库的路径。例如。