ApplicationConext
来源:互联网 发布:长沙优化网站排名 编辑:程序博客网 时间:2024/06/06 04:12
ApplicationContext是BeanFactory的子接口,AppllicationContext继承了好多接口,因此他也具备好多接口的功能。
BeanFactory是IOC的基本实现,主要负责bean配置文档的加载,管理,实例化,和维护bean之间的关系,负责bean生命周期等。
而ApplicationContext在BeanFactory的基础上添加 1、国际化 2、资源访问 3、事件传递等功能;
常用的获取ApplicationContext的方法有
FileSystemXmlApplicationContext:从文件系统和URL指定的xml配置文件中创建
ClasspathXmlApplicationConext:从Classpath中的xml配置文件中创建
webApplicationContextUtils:从web项目的根目录下读取配置文件,需要配置上面所说的监听器ContextLoaderListener或者是servlet来实现
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
他们都是默认配置文件是web_inf下的applicationContext.xml文件
如果需要改变路径可以使用
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:*.xml
</param-value>
</context-param>
其中<load-on-startup>1</load-on-startup>中间的整数的意思是这个Servlet加载的顺序1,2,3,4,5级别,如果是大于等于0表示立即加载,如果要是下于0,表示需要时在加载。
- ApplicationConext
- maven快速安装使用
- NOIP2016愤怒的小鸟 题解报告 【状压DP】
- Android 自定义AlertDialog
- 《高性能SQL调优精要与案例解析》一书谈主流关系库SQL调优(SQL TUNING或SQL优化)核心机制之——索引(index)
- Dalvik模式下基于Android运行时类加载的函数dexFindClass脱壳
- ApplicationConext
- 优先队列即堆:插入算法与删除算法JAVA
- Linux
- 持久区jvm堆内存溢出原因
- git 的常用命令总结
- centos7安装rabbitmq
- 【备忘】尚学堂白贺翔java互联网架构师视频教程下载
- 浪潮
- 单调队列