模板位于:abstract class AbstractXmlApplicationContext :
protected void loadBeanDefinitions(XmlBeanDefinitionReader reader) throws BeansException, IOException {
Resource[] configResources = getConfigResources(); //加载路径由子类去覆盖实现
if (configResources != null) {
reader.loadBeanDefinitions(configResources);
}
String[] configLocations = getConfigLocations();
if (configLocations != null) {
reader.loadBeanDefinitions(configLocations);
}
}
子类的实现:FileSystemXmlApplicationContext extends AbstractXmlApplicationContext
@Override
protected Resource getResourceByPath(String path) {
if (path != null && path.startsWith("/")) {
path = path.substring(1);
}
return new FileSystemResource(path);
}
资源的加载,是Spring IOC容器启动的第一步!