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:
SpringApplication.run(AppRun.class, args)
refreshContext(context)
refresh(context)
applicationContext.refresh()
super.refresh()
Enter the refresh method
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.
Come to the implementation class of onRefresh