spring中的BeanFactory与ApplicationContext的作用和区别
作用:
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来实现
org.springframework.web.context.ContextLoaderListener
context
org.springframework.web.context.ContextLoaderServlet
1
这两种方式都默认配置文件为web-inf/applicationContext.xml,也可使用context-param指定配置文件
contextConfigLocation
/WEB-INF/myApplicationContext.xml
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来实现
org.springframework.web.context.ContextLoaderListener
context
org.springframework.web.context.ContextLoaderServlet
1
这两种方式都默认配置文件为web-inf/applicationContext.xml,也可使用context-param指定配置文件
contextConfigLocation
/WEB-INF/myApplicationContext.xml
【spring中的BeanFactory与ApplicationContext的作用和区别】相关文章
1. spring中的BeanFactory与ApplicationContext的作用和区别
2. Spring中ApplicationContext的作用是什么
3. Spring里面applicationContext.xml文件能不能改成其他文件名
4. 如何在web环境中配置applicationContext.xml文件
5. 什么是Connection-oriented Protocol/Connectionless Protocol面向连接的协议/无连接协议
6. Spring对多种ORM框架提供了很好的支持,简单描述在Spring中使用Hibernate的方法
7. 简述你对Statement,PreparedStatement,CallableStatement的理解
8. 了解AppleShare protocol(AppleShare协议)吗
9. 介绍一下ICMP(Internet Control Message Protocol)Internet控制信息协议
10. what is the difference between ext2 and ext3
本文来源:https://www.mianshiwenti.com/a12605.html
进入下载页面
上一篇:EJB3推出JPA的原因
下一篇:介绍一下JMS编程步骤
﹝spring中的BeanFactory与ApplicationContext的作用和区别﹞相关内容
- 若通过ObjectOutputStream向一个文件中多次以追加方式写入object,为什么用ObjectInputStream读取这些object时会产生StreamCorruptedExcepti
- 软件测试LoadRunner面试题:Explain the Configuration of your systems
- 第一范式(1NF)、第二范式(2NF)和第三范式(3NF)之间的区别是什么?
- spring中的核心类有那些以及作用
- 软件测试LoadRunner面试题:What is correlation? Explain the difference between automatic correlation and manu
- 软件测试LoadRunner面试题:Explain the following functions: – lr_debug_message
- Spring里面如何定义hibernate mapping
- swtich是否能作用在byte上,是否能作用在long上,是否能作用在String上
- swtich是否能作用在byte上,是否能作用在long上,是否能作用在String上?
- Java的类可以定义为Protected或者Private得吗