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可以異步刷新配置文件。