本文配置中心使用的git
ConfigServicePropertySourceLocator.locate(..)
Environment result = getRemoteEnvironment(restTemplate,
properties, label.trim(), state);
response = restTemplate.exchange(uri + path, HttpMethod.GET,
entity, Environment.class, args);
通过这步,发送http请求,URL为
http://config-server-host:port/{application}/{proflie}
ResourceController下有对应的接口
@RequestMapping("/{name}/{profiles}/{label:.*}")
public Environment labelled(@PathVariable String name, @PathVariable String profiles,
@PathVariable String label) {
Environment environment = this.repository.findOne(name, profiles, label);
return environment;
}
到JGitEnvironmentRepository.getLocations()
@Override
public synchronized Locations getLocations(String application, String profile,
String label) {
if (label == null) {
label = this.defaultLabel;
}
String version = refresh(label);
return new Locations(application, profile, label, version,
getSearchLocations(getWorkingDirectory(), application, profile, label));
}
refresh()步骤:
1. 初始化临时仓库文件夹
2. fetch
3. checkout
4. merge
在临时仓库下,根据application和profile,加载配置信息,spring容器启动。