其他分享
首页 > 其他分享> > SpringBoot中bean的生命周期

SpringBoot中bean的生命周期

作者:互联网

  1. 实例化 Instantiation 
  2. 属性赋值 Populate
  3. 初始化 Initialization
  4. 销毁 Destruction
protected Object doCreateBean(final String beanName, final RootBeanDefinition mbd, final @Nullable Object[] args)
      throws BeanCreationException {

   // Instantiate the bean.
   BeanWrapper instanceWrapper = null;
   if (instanceWrapper == null) {
       // 实例化阶段
      instanceWrapper = createBeanInstance(beanName, mbd, args);
   }

   // Initialize the bean instance.
   Object exposedObject = bean;
   try {
       // 属性赋值阶段
      populateBean(beanName, mbd, instanceWrapper);
       // 初始化阶段
      exposedObject = initializeBean(beanName, exposedObject, mbd);
   }

   
   }

  



 

标签:exposedObject,生命周期,SpringBoot,mbd,beanName,instanceWrapper,bean,Object
来源: https://www.cnblogs.com/lostxxx/p/16244626.html