Spring中BeanFactory与ApplicationContext的区别
BeanFactory:Bean工厂接口,是访问Spring Bean容器的根接口,基本Bean视图客户端。从其名称上即可看出其功能,即实现Spring Bean容器的读取。
ApplicationContext:一个应用配置的中心接口,提供以下功能:
1.Bean factory methods for accessing application components,Inherited from {@link org.springframework.beans.factory.ListableBeanFactory}.(Bean工厂访问应用组件方法)
2.The ability to load file resources in a generic fashion.Inherited from the {@link org.springframework.core.io.ResourceLoader} interface.(以通用方式加载文件资源的能力)
3.The ability to publish events to registered listeners.Inherited from the {@link ApplicationEventPublisher} interface.(可以发布事件到注册监听器上的能力)
4.The ability to resolve messages, supporting internationalization.Inherited from the {@link MessageSource} interface.(处理消息的能力,支持国际化)
5.Inheritance from a parent context. Definitions in a descendant context will always take priority. This means, for example, that a single parent
context can be used by an entire web application, while each servlet has its own child context that is independent of that of any other servlet.
(可以继承一个上下文,定义一个派生上下文优先,例如,一个父上下文可以被整个网络应用,然而每一个servlet都有自己独立的子上下文。)
总结:举个简单的例子:整个应用比作一家企业的话,BeanFactory负责生产主管,而ApplicationContext则是CEO,总览全局,当然也包括生产主管BeanFactory。
BeanFactory和ApplicationContext对于bean后置处理器还有所不同,需要注意,ApplicationContext会自动检测在配置文件中实现了BeanPostProcessor接口的所有bean,
并把它们注册为后置处理器,然后在容器创建bean的适当时候调用它,因此部署一个后置处理器同部署其他的bean并没有什么区别。
而使用BeanFactory实现的时候,bean 后置处理器必须通过代码显式地去注册。
Spring中BeanFactory与ApplicationContext的区别的更多相关文章
- Spring中BeanFactory和ApplicationContext的区别
1. BeanFactory负责读取bean配置文档,管理bean的加载,实例化,维护bean之间的依赖关系,负责bean的生命周期. 2. ApplicationContext除了提供上述BeanF ...
- Spring中BeanFactory与FactoryBean的区别
在Spring中有BeanFactory和FactoryBean这2个接口,从名字来看很相似,比较容易搞混. 一.BeanFactory BeanFactory是一个接口,它是Spring中工厂的顶层 ...
- 【Java面试】Spring中 BeanFactory和FactoryBean的区别
一个工作了六年多的粉丝,胸有成竹的去京东面试. 然后被Spring里面的一个问题卡住,唉,我和他说,6年啦,Spring都没搞明白? 那怎么去让面试官给你通过呢? 这个问题是: Spring中Bean ...
- spring中BeanFactory和FactoryBean的区别
共同点: 都是接口 区别: BeanFactory 以Factory结尾,表示它是一个工厂类,用于管理Bean的一个工厂 在Spring中,所有的Bean都是由BeanFactory(也就是IOC容器 ...
- BeanFactory和ApplicationContext的区别(Bean工厂和应用上下文)
https://blog.csdn.net/qq_20757489/article/details/88543252 https://blog.csdn.net/pythias_/article/de ...
- Spring中的BeanFactory和ApplicationContext的区别
我用一个例子去测试BeanFactory和ApplicationContext的区别 首先建立一个bean public class User { //声明无参构造,打印一句话,监测对象创建时机 pu ...
- BeanFactory和ApplicationContext的区别+部分Spring的使用
BeanFactory和ApplicationContext的区别 ApplicationContext 方式加载:创建容器的同时 容器初始化,容器所有的bean创建完毕 Spring容器中获取一 ...
- Spring中ClassPathXmlApplication与FileSystemXmlApplicationContext的区别
Spring中ClassPathXmlApplication与FileSystemXmlApplicationContext的区别 一.概述 在项目中遇到加载不到Spring配置文件,简单分析后,写此 ...
- Spring中加载ApplicationContext.xml文件的方式
Spring中加载ApplicationContext.xml文件的方式 原文:http://blog.csdn.net/snowjlz/article/details/8158560 1.利用Cla ...
随机推荐
- 导入JSONPathExtractorExample.jmx文件报错,导不进去
导入之前写的JSONPathExtractorExample.jmx文件,导入不进来,报如下错,百度搜索说是缺少jar包 复制别人的信息如下 有的时候我们会参考别人的jmx文件,但是在导入的时候会报错 ...
- Zookeeper命令行auth,digest
一.auth auth:user:pwd:cdrwa digest:user:BASE64(SHA1(PWD)):cdrwa addauth digest user:pwd 增加用户和密码都是zhan ...
- Google program AB程序的基本理解
这个是2017年机器人项目中涉及到的一点东西,虽然没有派上什么大用场,但是还是有必要在这里记录一下! 1. 初始化Bot A. 配置各种路径,例如aiml,aimlif,config,set,map等 ...
- yii 生成条码并上传到图片服务器(zimg)
工具: 生成条码和二维码 https://github.com/codeitnowin/barcode-generator 配置:
- eval 日期对象
js中,eval相当于python中的eval(表达式)和exec(代码)的集合. var d = new Date(); #申明一个新的日期对象,方便之后调用,它的方法getDate();ge ...
- JavaScrip之BOM、DOM
BOM 浏览器对象模型(BrowserObjectModel),可以对浏览器窗口进行访问和操作.使用 BOM,开发者可以移动窗口.改变状态栏中的文本以及执行其他与页面内容不直接相关的动作. 使 Jav ...
- JAVA的debug入门和多断电调试
调试的一般都是逻辑 第一步的错误双击数字旁边的蓝色地方,或者点击右键如图 断点的意思就是程序执行在哪里就停止 当找不到DEBUG中的Variables是在位置输入Variables就可以了: 再按下F ...
- NutzWk 开发框架
官网: https://wizzer.cn/ 源码下载: https://github.com/wizzercn/NutzWk/ https://gitee.com/wizzer/NutzWk Int ...
- sqlserver触发器执行顺序【未经验证】
exec sp_settriggerorder @triggername = 'tr_customer_1', @order = 'first', @stmttype = 'insert',@name ...
- 检索COML类工厂中 CLSID为 {00024500-0000-0000-C000-000000000046}的组件时失败,原因是出现以下错误: 80070005" 《终结篇》
可以看到报出的异常类型为:UnauthorizedAccessException,没有权限访问,表明我们需要配置执行操作账户的COM访问权限. 由于系统是Windows Server 2008 64位 ...
