YON Blog

Get your hands dirty

用惯了 SpringBoot 都不知道一个 Web 服务到底怎么起来的了,就像用惯了 IDE 很多人连手写一个 Java 的 HelloWorld 并编译运行都做不到了。

SpringBoot 的启动依赖于 Servlet 3.0 的规范。3.0 以前 Servlet 启动是从读取 web.xml 文件开始的。3.0 开始支持不用配置 web.xml 启动,你只需要实现 ServletContainerInitializer 接口,然后基于 SPI 机制在
META-INF/services/javax.servlet.ServletContainerInitializer 文件里配上你的类名,这样 Tomcat 启动时就会基于 Servlet 规范执行你的类。SpringBoot 就是基于的这个机制。

另外补充下 SOFA 的启动, SOFA 会自动将 META-INF/spring 下的 Spring 配置文件加载.

明天早上起来如果下雨就不去晨跑去冥想了。

https://www.sofastack.tech/projects/sofa-boot/sofaboot-module/