1.ContextLoaderListener

1.1.ContextLoaderListener源码

public class ContextLoaderListener extends ContextLoader implements ServletContextListener {...}

ServletContextListener源码:

public interface ServletContextListener extends EventListener {    /**    web容器启动后,调用    **/    public default void contextInitialized(ServletContextEvent sce) {    }   /**    web容器敞开时调用,web将要敞开,还未敞开    **/    public default void contextDestroyed(ServletContextEvent sce) {    }}

ContextLoader: 用于spring 容器初始化类

public class ContextLoader {  ...}

1.2.流程

2.springBoot形式

2.1.流程

2.2.ServletWebServerApplicationContext

springboot在执行SpringAppliction.run办法时,创立的ApplicationContext是ServletWebServerApplicationContext,

改context实现了 AbstractApplicationContext.onRefresh办法,在onRefresh办法中创立了相应的web容器。