tomcat 启动时会读取web.xml文件
根据其中的配置:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
1. 首先读取<linstner>...</listener> 中的配置信息,创建ContextLoaderListener 的实例对象
2. 这个实例对象再去读取<context-param>...</context-param>中的配置信息,创建全部bean (比如sessionFactory)的实例,加载到内存中
3. sessionFactory 的实例会根据hibernate 的配置文件hibernate.cfg.xml ,生成对应的数据库表