IOC容器 bean生命周期

bean生命周期

GitHub code

img
  1. constructt method...null

  2. settingg method...spel city

  3. initt method...spel city

  4. BeanLifeCycle{cycle='spel city'} // 这个是 System.out.println(cycle1);

  5. destroyy method...spel city //容器关闭时调用

BeanPostProcessor在init方法前后处理bean

实现 org.springframework.beans.factory.config.BeanPostProcessor

GitHub Code

  1. constructt method...null

  2. settingg method...spel city

  3. postProcessBeforeInitialization: bean=BeanLifeCycle{cycle='spel city'} beanName=cycle1

  4. initt method...spel city

  5. postProcessAfterInitialization: bean=BeanLifeCycle{cycle='spel city'} beanName=cycle1

  6. BeanLifeCycle{cycle='spel city'} // 这个是 System.out.println(cycle1);

  7. destroyy method...spel city //容器关闭时调用

img

Last updated

Was this helpful?