spring cloud使用Spring Cloud Bus配合RabbitMQ刷新配置,使用Spring boot2.0与spring cloud Finchley.RC2

    

因为spring boot2.0与spring boot 1.5有这很大区别,而网上关于使用RabbitMq的教程大都使用spring boot1.5,所有在使用spring boot2.0时网上的教程多数不起作用。以下是主spring boot2.0相较于spring boot1.5主要改变

  1. 首先在屏蔽安全验证的代码在1.5中应该
management:
  security:
    enable: false

而在2.0中应该是

management:
  endpoints:
    web:
      exposure:
        include: bus-refresh

在和config cilent服务的配置文件中加上上述配置代码屏蔽安全验证;

2.其次,在config server段除了需要导入amqp的启动依赖,还需要actuator的启动依赖。pom代码如下

 <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-bus-amqp</artifactId>
        </dependency>
3.最后在想config client服务发送post请求时,用 http://localhost:8762/actuator/bus-refresh替换http://localhost:8762/bus/refresh,如果使用http://localhost:8762/bus/refresh会返回404错误




                
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值