1、首先配置rabbitmq。在pom文件中新增包
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
2、在git的config工程中修改application.yml中,配置rabbitmq的IP和端口号
rabbitmq:
host: 10.2.33.22
port: 5672
username: admin
password: admin
publisher-confirms: true # 生产者消息确认
addresses: 10.2.33.22 # 客户端访问server地址, 作为发送者,配置和host一致
3、修改application.yml,配置bus-refresh无需token安全校验。
management:
endpoints:
web:
base-path: /management
exposure:
include: ["configprops", "env", "health", "info", "threaddump", "logfile","bus-refresh"]
endpoint:
health:
show-details: when_authorized
health:
mail:
enabled: false
4、启动registry工程,直接调用http://127.0.0.1:8761/management/bus-refresh可以异步刷新配置文件。