[SpringBoot3.0 source code] built-in tomcat startup source code analysis

I don’t know if you have experienced the framework combination of SSM before, packaging the project into a war, deploying it in the Tomcat container, and starting it. In other words, the startup of the Tomcat server drives the loading of the IOC container.

SpringBoot has built-in Tomcat, that is, on the contrary, the loading of the IOC container is accompanied by the startup of the Tomcat service.

Let's analyze how SpringBoot's built-in Tomcat starts based on the SpringBoot source code.

First, from the main function entry:

  1. SpringApplication.run(AppRun.class, args)
  2. refreshContext(context)
  3. refresh(context)
  4. applicationContext.refresh()
  5. super.refresh()

Enter the refresh method

insert image description here

When we talked about IOC earlier, we talked about this method, this refresh method, using template design, which can improve code reusability and scalability.

It is not as good as the onRefresh method, which is an empty method.
insert image description here
Come to the implementation class of onRefresh

Guess you like

Origin blog.csdn.net/CSDN_SAVIOR/article/details/128910083