Spring配置文件加载流程

来源:互联网 发布:telnet linux 命令 编辑:程序博客网 时间:2024/04/28 09:52

Spring配置文件是集成了Spring框架的项目的核心,引擎从哪里开始,中间都执行了哪些操作,小谈一下它的执行流程。

容器先是加载web.xml

 

接着是applicationContext.xml在web.xml里的注册

 

一种方法是加入ContextLoaderServlet这个servlet

还有一种是添加ContextLoaderListener这个监听器

下面是ContextLoaderServlet源代码

ContextLoaderListener源代码

 以上都提到了ContextLoader这个类

ContextLoaderServlet和ContextLoaderListener都是先创建ContextLoader的一个对象,然后调用它的initWebApplicationContex方法初始化WebApplicationContext获得一个对象;

原创粉丝点击