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()
The second part of the source code
Main method: refreshContext()—>refresh()–>invokeBeanFactoryPostProcessors()–>parse()
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