欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

spring容器启动方式

程序员文章站 2022-07-14 08:49:21
...
什么时候spring容器启动?
其实就是程序中执行加载 xml配置文件的时候
1.应用程序下加载
ApplicationContext ctx = new ClassPathXmlApplicationContext("testspring2.xml");

2.web模式下加载
web.xml:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-hibernate-mysql.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>