細扒之繼續講容器初始化流程,上篇講了super(parent),本章初始化的下一步setConfigLocations(configLocations);大佬請略過
setConfigLocations(configLocations)對應源碼
public void setConfigLocations(@Nullable String... locations) {
if (locations != null) {
Assert.noNullElements(locations, "Config locations must not be null");
this.configLocations = new String[locations.length];
for (int i = 0; i < locations.length; i++) {
this.configLocations[i] = resolvePath(locations[i]).trim();
}
}
else {
this.configLocations = null;
}
}
protected String resolvePath(String path) {
return getEnvironment().resolveRequiredPlaceholders(path);
}
源碼的註釋其實寫得比較明瞭,一句話概括了:設置此應用程序上下文的配置位置,如果未設置,則實現可酌情使用默認值。