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 ...
随机推荐
- java-常用注解
JDK自带注解 @Override 重写, 标识覆盖它的父类的方法 @Deprecated 已过期,表示方法是不被建议使用的 @Suppvisewarnings 压制警告,抑制警告 元注解 @Ta ...
- ASP.NET AJAX入门系列(11):在多个UpdatePanle中使用Timer控件
本文将使用Timer控件更新两个UpdatePanel控件,Timer控件将放在UpdatePanel控件的外面,并将它配置为UpdatePanel的触发器,翻译自官方文档. 主要内容 在多个Upda ...
- redis : 桌面管理工具 redis-desktop-manager使用指南
概要:一款好用的Redis桌面管理工具,支持命令控制台操作,以及常用,查询key,rename,delete等操作. 下载软件,请点击下面链接,进入下载页,选择对应版本: https://redisd ...
- MBR详解
我们通常对磁盘分区时,都会涉及到MBR和GPT.MBR和GPT都是磁盘分区的类型,由于以前的硬盘只有几个GB,几十个GB,几百个GB,使用MBR类型分区已经足够.但是近些年来,硬盘容量的发展速度迅速, ...
- class path resource [spring/ApplicationContext-springmvc.xml] cannot be opened because it does not exist
配置如下: <init-param> <param-name>contextConfigLocation</param-name> <param-va ...
- php结合phantomjs实现网页截屏、抓取js渲染的页面
首先PhantomJS快速入门 PhantomJS是一个基于 WebKit 的服务器端 JavaScript API.它全面支持web而不需浏览器支持,其快速,原生支持各种Web标准: DOM 处理, ...
- pandas初识
pandas初识 1.生成DataFrame型的数据 import pandas as pd import numpy as np dates = pd.date_range('20130101',p ...
- docker配置ftp服务器
docker run --name ftp_server -d -v ~/Projects/ftp:/home/vsftpd -p : -p : -p -:- -e FTP_USER=ftp -e F ...
- 黄聪:is_file和file_exists效率比较
目前在弄文件缓存的时候用到了判定文件存在与否,is_file()还是file_exists()呢?is_file和file_exists两者效率比较起来,谁的运行速度更快呢?还是做个测试吧: 1 2 ...
- java设计模式-工厂系列
一.简单工厂 1.背景: 任意定制交通工具的类型和生产过程 代码: Moveable.java package com.cy.dp.factory; public interface Moveable ...
