Spring Cloud 配置服务器不刷新 [英] Spring Cloud Config Server Not Refreshing
问题描述
我正在设置一个 Spring 云服务器来读取内部 Stash 目录.
I'm setting up a Spring cloud server to read of an internal Stash directory.
服务器第一次加载正常,但如果我更新 git 中的属性,它们不会得到反映,直到我重新启动云服务器(我尝试 POST 到/refresh 端点).
The server loads up ok the first time, but if I update properties in git, they don't get reflected until I restart cloud server (I try POST to /refresh endpoint).
我使用的是 Windows,我看到一些与 Windows 上的服务器相关的错误,但我没有看到任何关于我的错误的具体提及.
I'm on Windows and I see a few bugs related to server on Windows but I don't see any specific mention of my bug.
推荐答案
参见 org.springframework.cloud.bootstrap.config.RefreshEndpoint代码在这里:
see org.springframework.cloud.bootstrap.config.RefreshEndpoint code here:
public synchronized String[] refresh() {
Map<String, Object> before = extract(context.getEnvironment()
.getPropertySources());
addConfigFilesToEnvironment();
Set<String> keys = changes(before,
extract(context.getEnvironment().getPropertySources())).keySet();
scope.refreshAll();
if (keys.isEmpty()) {
return new String[0];
}
context.publishEvent(new EnvironmentChangeEvent(keys));
return keys.toArray(new String[keys.size()]);
}
这意味着/refresh端点先pull git然后刷新catch,并公开一个environmentChangeEvent,这样我们就可以像这样客户化代码.
that means /refresh endpoint pull git first and then refresh catch,and public a environmentChangeEvent,so we can customer the code like this.
这篇关于Spring Cloud 配置服务器不刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!