Spring容器相关。目前在了解Spring的容器的相关信息之后,觉得在这部分初期阶段其实不需要知道Spring容器内部实现,只需要对Spring容器有一个整体的认识就可
什么是Spring容器?
- 这个是国外一个教程对Spring容器的一个定义(个人认为讲得非常精简):The Spring container is at the core of the Spring Framework. The container will create the objects, wire them together, configure them, and manage their complete life cycle from creation till destruction. The Spring container uses DI to manage the components that make up an application. 接下来对它的描述进行拆解
- Spring容器是Spring framework的核心
- Spring容器创建了spring bean、并将这些spring bean进行关联,同时根据配置spring-bean进行扩展。
- Spring容器管理了spring bean创建到销毁的整个过程
- Spring容器采用了依赖注入的方式来管理spring bean
Spring容器分类
- 现有的Spring只有两类容器
- Spring BeanFactory Container
- 由org.springframework.beans.factory.BeanFactory接口定义
- 提供了最基础的依赖注入的功能
- 存在与spring-beans模块当中
- Spring ApplicationContext Container
- 由org.springframework.context.ApplicationContext interface定义
- 相比较于BeanFactory,ApplicationContext提供了更强大的功能,例如event listeners
- Spring BeanFactory Container