首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring Cloud Bus不工作/bus/refresh调用到控制器并在控制器中查找映射失败

Spring Cloud Bus不工作/bus/refresh调用到控制器并在控制器中查找映射失败
EN

Stack Overflow用户
提问于 2017-05-28 01:29:29
回答 1查看 1.7K关注 0票数 1

我已经使用配置服务器和github支持的外部配置文件配置了我的应用程序。当我在cloud foundry中拥有我的应用程序的单个实例时,它工作得很好。

但是对于多个实例,据说实现了spring cloud bus来将外部配置更改应用到所有实例。为此,我将我的配置服务器与Pivotal Cloud foundry上提供的rabbit实例绑定在一起。在我的build.gradle文件中添加了spring.cloud.starter.bus.amqp jar。

问题:但是当我在http://server:port/bus/refresh向客户端应用程序发送POST请求时,调用会转到控制器,而不是刷新所有实例,并且由于没有映射而失败。

如果我缺少任何配置来使spring-cloud-bus工作,请告诉我。提前感谢!

Application.properties(客户端应用程序):

代码语言:javascript
复制
spring.profiles=cloud  
spring.rabbitmq.host= 10.17.128.102
spring.rabbitmq.port= 5672
spring.rabbitmq.virtual-host= *****
spring.rabbitmq.username= ******
spring.rabbitmq.password= *****
rabbit.exchangeName= demoPartyServiceexc
rabbit.routingKey= demoPartyService
rabbit.queueName= demoPartyServicequeue
logging.level.ROOT= ERROR 

Bootstrap.properties(客户端应用程序):

代码语言:javascript
复制
spring.application.name=demo-api
spring.cloud.bus.enabled=true
spring.cloud.config.bus.enabled=true
spring.cloud.bus.amqp.enabled=true
spring.cloud.bus.refresh.enabled=true
spring.cloud.bus.env.enabled=true
spring.cloud.config.uri=https://config-a5e99419-8179-47f7-8c23-62ed5b38db0b.cf.com
spring.cloud.config.server.bootstrap=true
spring.cloud.config.server.git.uri= My Github repository URI
spring.cloud.config.server.git.username= ********
spring.cloud.config.server.git.password= ********

GIT repo中的application.properties文件:

代码语言:javascript
复制
logging.level.ROOT=WARN
EN

回答 1

Stack Overflow用户

发布于 2017-05-30 22:42:06

客户端应用程序中的server.servlet-pathmanagement.context-path设置为什么?

我认为您可能需要将请求发送到http://host/<management.context-path>/bus/refresh

或者更好的是,发送到http://config-server-host/monitor,这样它就可以向RabbitMQ中的主题发布消息,并且所有客户端应用程序都会收到通知。

配置片段、源代码和更多细节可以在我的博客帖子中找到:Refreshable Configuration using Spring Cloud Config Server, Spring Cloud Bus, RabbitMQ and Git

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44219786

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档