最近在学习springcloud集成,在看到消息总线这块儿的时候照着网上的方法做了个测试,但是在访问localhost:端口号/actuator/bus-refresh这个接口以后,并没有获取到远程配置的更改,我客户端的controller类,也加了@Rescope这个注解,但是我的服务端的控制台我看返回的是
o.s.cloud.bus.event.RefreshListener : Received remote refresh request. Keys refreshed []
这是不是服务端上就没有获取到更新的意思?
我还要自己在浏览器输入
localhost:12000/base-dev.yml
这个以后,控制台才能获取显示
Fetched for remote master and found 1 updates
好像消息总线服务端压根儿就没有生效,而且我服务端获取了消息后,客户端也没有发生变化,还是需要重启才能重新加载配置更改,请高人指点下,我是不是哪里配置或是依赖错了,谢谢。
我的springboot是2.2.4,springcloud是Hoxton.SR3,不知道是不是跟版本用的太新了有关系,因为配置上实在是看不出问题了,只是不生效,没有任何报错信息
服务端application.yml
server:
port: 12000
spring:
application:
name: bus-server
cloud:
config:
server:
git:
uri: ********
username: ******
password: ******
rabbitmq:
host: 192.168.159.130
username: guest
password: guest
#暴露触发消息总线的地址
management:
endpoints:
web:
exposure:
include: 'bus-refresh'
客户端bootstrap.yml
spring:
cloud:
config:
name: base
profile: dev
label: master
uri: http://127.0.0.1:12000
远程配置文件dev-base.yml
server:
port: 9001
spring:
application:
name: bus-client
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/testclient?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false
username: root
password: root
jpa:
database: mysql
show-sql: true
rabbitmq:
host: 192.168.159.130
username: guest
password: guest
eureka:
client:
service-url:
defaultZone: http://127.0.0.1:6868/eureka/
instance:
prefer-ip-address: true
pom.xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bus</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>