一.IoC 容器 IoC 容器是 Spring 的核心,Spring 通过 IoC 容器来管理对象的实例化和初始化(这些对象就是 Spring Bean),以及对象从创建到销毁的整个生命周期.也就是管理对象和依赖,以及依赖的注入等等. Spring 提供 2 种不同类型的 IoC 容器:BeanFactory 和 ApplicationContext 容器. 1.1 BeanFactory 容器 BeanFactory 是一个管理 Bean 的工厂,它主要负责初始化各种 Bean, 并调用它们的…
Life Cycle Management of a Spring Bean 原文地址:http://javabeat.net/life-cycle-management-of-a-spring-bean/ 1) Introduction This article would brief about how a Spring Bean is managed in IOC (Inversion of Control) Container. Spring Beans exist within the…
装配 Bean 的概述 前面已经介绍了 Spring IoC 的理念和设计,这一篇文章将介绍的是如何将自己开发的 Bean 装配到 Spring IoC 容器中. 大部分场景下,我们都会使用 ApplicationContext 的具体实现类,因为对应的 Spring IoC 容器功能相对强大. 而在 Spring 中提供了 3 种方法进行配置: 在 XML 文件中显式配置 在 Java 的接口和类中实现配置 隐式 Bean 的发现机制和自动装配原则 方式选择的原则 在现实的工作中,这 3 种方…
Spring Bean: 被称作bean的对象是构成应用程序的支柱,是由Spring Ioc容器管理.bean是一个被实例化,配置.组装并由Spring Ioc容器管理对象. 官网API:A Spring IoC container manages one or more beans. These beans are created with the configuration metadata that you supply to the container, for example, in…