模板位于: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容器启动的第一步!
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-10-09 06:08:46