Springboot automatic assembly flowchart and source code

insert image description here
The process summarizes two parts: prepareContext + refreshContext
1.
prepareContext 1.1 load method, encapsulate the startup class as beanDefinition and register it in bedefinitionMap
2.
refreshContext 2.1 invokeBeanFactoryPostProcessor
2.1.1 parse method, recursively scan the annotations on the startup class, determine the basePackage, and load the component annotation modification Class
2.1.2 Scanning and parsing @Import will load the class information that needs to be automatically assembled, and finally register it in beanDefinitionMap

The first part of the source code

Main method: prepareContext –> load()
insert image description here
insert image description here
insert image description here
insert image description hereinsert image description here

insert image description here

The second part of the source code

Main method: refreshContext()—>refresh()–>invokeBeanFactoryPostProcessors()–>parse()
insert image description here
insert image description here
insert image description here
insert image description here
insert image description hereinsert image description here
insert image description hereinsert image description here

insert image description here
insert image description here
insert image description here

insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description hereinsert image description hereinsert image description here

insert image description here
insert image description here

insert image description here
insert image description here
insert image description hereinsert image description here
insert image description here
insert image description here

All registration information has been prepared, // Instantiate all remaining (non-lazy-init) singletons.finishBeanFactoryInitialization (beanFactory); method in refresh
will reflect and create all non-lazy-loaded beans...

Finally, let's take a look at the SpringBoot startup class annotations

insert image description here
insert image description here

insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/GiantCrocodile/article/details/124799016
Recommended