Spring Cloud Config Server Not Refreshing

江枫思渺然 提交于 2019-12-08 02:41:41

问题


I'm setting up a Spring cloud server to read of an internal Stash directory.

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).

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.


回答1:


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()]);
}

that means /refresh endpoint pull git first and then refresh catch,and public a environmentChangeEvent,so we can customer the code like this.



来源:https://stackoverflow.com/questions/32364240/spring-cloud-config-server-not-refreshing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!