SpringCloud Config手动刷新及自动刷新
1、Config手动刷新
a、使用@RefreshScope注解
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 这边的@RefreshScope注解不能少,否则即使调用/refresh,配置也不会刷新
*/
@RestController
@RefreshScope
public class ConfigClientController {
@Value("${env}")
private String env;
@Value("${password}")
private String password;
@Value("${username}")
private String username;
@GetMapping("/config/profile")
public String hello() {
return this.env+","+this.password+","+this.username;
}
}
b、post请求config客户端的/refresh端点
http://localhost:6062/refresh
再次访问http://localhost:6062/config/profile,发现配置文件为最新配置。
2、Config自动刷新
1、WebHooks动态刷新
2、spring-cloud-bus动态刷新
分类:
SpringCloud
, SpringBoot
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 写一个简单的SQL生成工具
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
2012-01-30 二、oracle sql*plus常用命令