The startup process of SpingBoot

Springboot is a new lightweight framework based on spring, and the most powerful part is automatic configuration. Then we can take a look at how to achieve automatic configuration based on the startup process and related principles.
Start flow chart


1. SpringAplication starts, run the run method to create a new SpringApplication object, and initialize the SpringApplication object

Call the run method to
Spring boot default startup class
create a new SpringApplication object to
Insert picture description here
initialize the SpringApplication object
Insert picture description here

Second, the run method of the SpringApplication object creates and starts the timing monitoring class

Insert picture description here

Three, set the value of java.awt.headless through configureHeadlessProperty

Insert picture description here
Specific setting method
Insert picture description here

Fourth, call getRunListeners to create all spring listeners

Insert picture description here

Five, initialize application parameters through DefaultApplicationArguments

Insert picture description here

Six, prepare the spring environment according to the running listener and parameters through prepareEnvironment

Insert picture description here

Seven, call the createApplicationContext method to create an application context

Insert picture description here
Insert picture description here

Eight, prepare the application context through prepareContext

Insert picture description here
Insert picture description here

Nine, refresh the context through the refreshContext method

Insert picture description here

10. Call the stop method to stop the timing monitor class

Insert picture description here

11. Call started to publish the application context start completion event

Insert picture description here

Twelve, call the callRunners method to execute all runner runners

Insert picture description here

Thirteen, call running to publish the application context ready event

Insert picture description here

14. Finally return to the application context

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_42697271/article/details/113844408