使用SpringCloud finchley 和 SpringBoot 2.0+
还需要引入
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
第一点是最新版本更改了,Spring boot 2.0的改动较大,/bus/refresh全部整合到actuador里面了,所以之前1.x的management.security.enabled全部失效,不适用于2.0
最新刷新请求接口: http://localhost:8881/actuator/bus-refresh
是一个post的请求
端口号是需要刷新的项目接口(也就是client项目)。
重要的是@RefreshScope 需要加在 @Value的类上面,并不是启动类上面。
RefreshScope(org.springframework.cloud.context.scope.refresh
)是spring cloud提供的一种特殊的scope实现,用来实现配置、实例热加载。
对于
management:
endpoints:
web:
exposure:
include: bus-refresh
只加载Client的配置就行。