Spring源码:Spring 容器资源加载模板模式应用

Spring源码:Spring 容器资源加载模板模式应用

分类:JAVAEE

模板位于: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

@Overrideprotected Resource getResourceByPath(String path) {if (path != null && path.startsWith("/")) {path = path.substring(1);}return new FileSystemResource(path);}资源的加载,,是Spring IOC容器启动的第一步!

版权声明:本文为博主原创文章,未经博主允许不得转载。

上一篇MyBatis与Spring 整合后,创建Bean报奇葩错的解决

顶0踩0

不甚酒力,体会不了酒的美味,但却能感受知已的妙处。

Spring源码:Spring 容器资源加载模板模式应用

相关文章:

你感兴趣的文章:

标签云: