Python 官方文档:入门教程 => 点击学习
目录背景实现原理ConfigServer改造1. pom.xml增加以下依赖2. 配置文件中配置暴露接口Service改造1. pom.xml增加以下依赖2. 通过@RefreshS
使用spring cloud Config Server,
启动Service时会从配置中心取配置文件,并注入到应用中,如果在Service运行过程中想更新配置,需要使用spring Cloud Bus配合实现实时更新。
目标:使ConfigServer暴露bus-refresh接口,通过bus通知服务更新配置
<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>
management.endpoints.WEB.exposure.include=bus-refresh
<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>
@RefreshScope
@Controller
public class LblController {
1. 修改git仓库上的配置文件
Service配置没有更新
2. 调用http://localhost:8081/actuator/bus-refresh(POST)
Service配置更新
本篇文章就到这里了,希望能够给你带来帮助,也希望您能够多多关注编程网的更多内容!
--结束END--
本文标题: Java Spring Cloud Bus 实现配置实时更新详解
本文链接: https://www.lsjlt.com/news/135729.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0