【SpringBoot3.0源码】内置tomcat启动源码解析

不知道大家以前是否经历过SSM这种框架组合,将项目打包成war,部署到Tomcat容器中,进行启动。也就是说,Tomcat服务器的启动带动了IOC容器的加载。

SpringBoot内置了Tomcat,那就是相反,IOC容器的加载,伴随着Tomcat服务的启动。

我们就SpringBoot源码,来分析一下SpringBoot内置的Tomcat是如何启动的。

首先,从主函数入口:

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

进入refresh方法

在这里插入图片描述

前面谈到IOC的时候,讲过这个方法,这个refresh方法,使用了模版设计,可以提高代码复用性和扩展性。

不如onRefresh方法,是个空方法。
在这里插入图片描述
来到onRefresh的实现类中

猜你喜欢

转载自blog.csdn.net/CSDN_SAVIOR/article/details/128910083