spring Bean介绍

2019-05-23  本文已影响0人  不存在的里皮

前言

偶然看到BeanDefinition类后,我思索spring解析<bean>标签后生成了什么类的对象?它是怎么做到钩子函数的,是回调函数,还是用了动态代理机制?BeanDefinition和@Bean有什么关系吗?

什么是Bean

Bean 定义

Bean的生命周期

JAVA面试题:Spring中bean的生命周期

  1. 实例化
  2. 设置属性。Setter注入。
  3. 各种Aware接口调用
  4. BeanPostProcessor.postProcessBeforeInitialization
  5. InitializingBean.afterProPertiesSet
  6. init-method(如果有设置)
  7. BeanPostProcessor.postProcessAfterInitialization

然后Bean可以正常使用。


容器关闭时

  1. DisposableBean.destroy
  2. destroy-method(如果有配置)

Spring循环依赖检查

Spring循环依赖检查

内部Bean级联 inter-bean-dependencies

单例Bean与原型Bean的相互引用

...

上一篇 下一篇

猜你喜欢

热点阅读