Spring advanced source code notes: Spring Bean creation process comprehensive analysis of the accompanying code implementation!

Bean creation process

  • The key point analysis by the timing of the beginning, we knew Bean create sub-process entry AbstractApplicationContext#refresh()method finishBeanFactoryInitialization(beanFactory)at
  • enterfinishBeanFactoryInitialization

  • Continue to enter DefaultListableBeanFactorythe preInstantiateSingletons method of the class , we find the following part of the code, see the factory Bean or ordinary Bean , and finally getBeanget the instance through the method

  • Continuing to track down, we have entered AbstractBeanFactorythe doGetBean method of the class. There are a lot of codes in this method, and we directly find the core part

  • Then enter AbstractAutowireCapableBeanFactorythe method of the class, find the following code part
  • Enter the doCreateBean method to see, this method we focus on two key areas
  • Create a Bean instance, the properties have not been set at this time

  • Fill the Bean with attributes, call the initialization method, and apply the BeanPostProcessorpost processor

This article references "Spring Advanced Source Notes", students who need to add assistant VX: C18173184271 free access

If you need this full version of "Spring Advanced Source Notes", you only need to support my article.

A lot of support, you can get information for free-after three consecutive years (promise: 100% free)

Quick start channel: Add assistant VX: C18173184271 Get it for free! Full of sincerity! ! !

Spring interview feature article click here! ! !

Guess you like

Origin blog.csdn.net/Java_Caiyo/article/details/112986545