Spring中BeanFactory、ApplicationContext区别
来源:互联网 发布:传奇归来网络传输异常 编辑:程序博客网 时间:2024/05/22 20:36
作用:
1. BeanFactory 负责读取bean配置文档,管理bean的加载,实例化,维护bean之间的依赖关系,负责bean的声明周期。
2. ApplicationContext 除了提供上述BeanFactory所能提供的功能之外,还提供了更完整的框架功能:
a. 国际化支持
b. 资源访问:Resource rs = ctx. getResource(“classpath:config.properties”), “file:c:/config.properties”
c. 事件传递:通过实现ApplicationContextAware接口
3. 常用的获取ApplicationContext的方法:
FileSystemXmlApplicationContext:从文件系统或者url指定的xml配置文件创建,参数为配置文件名或文件名数组
ClassPathXmlApplicationContext:从classpath的xml配置文件创建,可以从jar包中读取配置文件(经常使用)
WebApplicationContextUtils:从web应用的根目录读取配置文件,需要先在web.xml中配置,可以配置监听器或者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指定配置文件
<context-param>
< param-name>contextConfigLocation</param-name>
< param-value>/WEB-INF/myApplicationContext.xml</param-value>
< /context-param>
以上内容来自网络:http://www.mianwww.com/html/2009/08/3486.html
- Spring中BeanFactory、ApplicationContext区别
- Spring中ApplicationContext和beanfactory区别
- Spring中BeanFactory与ApplicationContext的区别
- Spring中ApplicationContext和beanfactory区别
- spring 中beanFactory和ApplicationContext的区别
- Spring中ApplicationContext和beanfactory区别
- Spring中ApplicationContext和beanfactory区别
- Spring中ApplicationContext和beanfactory区别
- spring 中ApplicationContext与beanfactory的区别
- Spring中ApplicationContext和beanfactory区别
- Spring中ApplicationContext和beanfactory区别
- Spring中ApplicationContext和beanfactory区别
- Spring中ApplicationContext和beanfactory区别
- Spring中ApplicationContext和beanfactory区别 .
- Spring中ApplicationContext和beanfactory区别
- 【转】Spring中ApplicationContext和beanfactory区别
- Spring中ApplicationContext和beanfactory区别
- spring 中beanFactory和ApplicationContext的区别
- POJ 3683 Priest John's Busiest Day (2 - SAT) - from lanshui_Yang
- 利用nfs挂在根文件系统
- linux下mysql数据库的rpm安装步骤及常见问题的解决
- python项目练习九:文件共享2-GUI版本
- socket 套接字编程笔记——IP地址转换
- Spring中BeanFactory、ApplicationContext区别
- python项目练习十:DIY街机游戏
- Linux之TCP/IP
- 网络协议
- Java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet解决办法
- DMA映射 dma_addr_t
- Linux嵌入式工程师成长经历
- callback函数
- cocos2d-x进度条的实现