Spring专题学习

3.Spring容器

2018-09-07  本文已影响0人  Lee_java

这篇文章主要介绍Spring中的容器
在Spring中也同样存在容器,而且Spring的容器是负责创建对象,装配bean,配置Bean并管理它们的整个生命周期。
Spring中存在多种容器,大概可以分为以下的两类:
1.bean工厂:org.springframework.beans.factory.BeanFactory接口定义,提供基本的依赖注入支持。
2.应用上下文:org.springframework.context.ApplicationContext接口定义,基于BeanFactory创建,并且提供应用框架级别的服务。
(1)AnnotationConfigApplicationContext:从一个或者多个基于Java配置类中加载Spring应用上下文。
(2)AnnotationConfigWebApplicationContext:从一个或多个基于Java配置类加载SpringWeb应用上下文。
(3)ClassPathXmlApplicationContext:从类路径下的一个或者多个XML配置文件中加载上下文定义,把应用上下文的定义文件作为类资源。
(4)FileSystemXmlApplicationContext:从文件系统下的一个或者多个XML配置文件中加载上下文定义。
(5)XmlWebApplicationContext:从web应用下的一个或者多个XML配置文件中加载上下文定义。
3.ClassPathXmlApplicationContext和FileSystemXmlApplicationContext的区别:
ClassPathXmlApplicationContext是在所有类路径下查找XML配置文件;
FileSystemXmlApplicationContext是在文件系统路径下查找XML配置文件。

上一篇下一篇

猜你喜欢

热点阅读