框架版本
Spring Boot版本:2.0.3
Spring Cloud版本:Finchley
Kafka版本:2.0.0
遇到的问题
我按照博客:史上最简单的SpringCloud教程 | 第八篇: 消息总线(Spring Cloud Bus)(Finchley版本)配置之后,在发送post请求:http://localhost:8881/actuator/bus-refresh 后,报出了404的错误,半天摸不到头绪,不过肯定是配置上出了问题,一定要确保以下几点配置:
1.必须在config-client中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-kafka</artifactId>
</dependency>
2.必须在config-client配置文件中添加以下配置:
management:
endpoints:
web:
exposure:
include: bus-refresh
3.必须在调用@Value注解类上添加注解:
@RefreshScope
4.请求刷新的页面由原来1.5.x的localhost:8881/bus/refresh,变成:http://localhost:8881/actuator/bus-refresh,因为Spring boot 2.0的改动较大,/bus/refresh全部整合到actuador里面了。
config-server配置:
1.pom.xml文件:
<?xml version="1.0" encoding="UTF-8