我想重新绑定ConfigurationProperties data.Read用户文档。post http://localhost:8080/env,起作用了。但是post http://localhost:8080/env/reset不能刷新所有配置。只能刷新访问过/env的密钥。我想刷新所有的配置,我应该怎么做?
endpoints
发布于 2018-06-21 01:08:19
将键值对发送到/env将触发rebinding。在/env/reset属性源不为空的情况下,向manager投递也会触发。
如果不通过发布/env更新环境,则可以使用端点/refresh。
@ManagedOperation
public Map<String, Object> reset() {
Map<String, Object> result = new LinkedHashMap<String, Object>(map);
if (!map.isEmpty()) {
map.clear();
publish(new EnvironmentChangeEvent(publisher, result.keySet()));
}
return result;
}
@ManagedOperation
public void setProperty(String name, String value) {
if (!environment.getPropertySources().contains(MANAGER_PROPERTY_SOURCE)) {
synchronized (map) {
if (!environment.getPropertySources().contains(MANAGER_PROPERTY_SOURCE)) {
MapPropertySource source = new MapPropertySource(
MANAGER_PROPERTY_SOURCE, map);
environment.getPropertySources().addFirst(source);
}
}
}
if (!value.equals(environment.getProperty(name))) {
map.put(name, value);
publish(new EnvironmentChangeEvent(publisher, Collections.singleton(name)));
}
}https://stackoverflow.com/questions/50940976
复制相似问题