【黑马程序员SpringBoot2全套视频教程,springboot零基础到项目实战(spring boot2完整版)】
之前我们已经看到了源码的这个位置:

两个run 调用

现在我们点进这个“构造方法”


可以看到,还是没有跳出这个类
public SpringApplication(Class>... primarySources) {
this((ResourceLoader)null, primarySources);
}
ResourceLoader:资源加载器
OK,接着往下走,看看它又调用了谁,this
点进去

可以看到直接下来了
public SpringApplication(ResourceLoader resourceLoader, Class>... primarySources)
这个构造方法进行了一些什么操作?
来品一下
this.resourceLoader = resourceLoader;
传过来的resourceLoader ,将其初始化为一个成员变量【为了方便使用、升级了作用范围】
Assert.notNull(primarySources, "PrimarySources must not be null");
判断传过来的这个启动类是不是空
this.primarySources = new LinkedHashSet(Arrays.asList(primarySources));
传过来的参数去重转为一个LinkedHashSet 集合 的对象,保存到一个成员变量备用【为了内部操作便利,初始化配置类的类名信息(格式上转换)】
this.webApplicationType = WebApplicationType.deduceFromClasspath();
在这儿打一个断点

现在是个NONE,改个东西
依赖改为web

再次运行

这次就是servlet 了
恢复pom 文件依赖

就是判断当前环境是否是一个web 环境【确认当前容器类型】