1.ContextLoaderListener1.1.ContextLoaderListener源码publicclassContextLoaderListenerextendsContextLoaderimplementsServletContextListener{...}ServletContextListener源码:publicinterfaceServletContextListenerextendsEventListener{/**web容器启动ub后调用default/publicvoidcontextInitialized(ServletContextEventsce){}/**web容器关闭时调用,web即将关闭,但还未关闭**/publicdefaultvoidcontextDestroyed(ServletContextEventsce){}}ContextLoader:用于spring容器初始化类publicclassContextLoader{...}1.2。流程2.springBoot方法2.1.过程2.2。ServletWebServerApplicationContextspringboot执行SpringApplication.run方法时,创建的ApplicationContext为ServletWebServerApplicationContext,改上下文实现AbstractApplicationContext.onRefresh方法,在onRefresh方法中创建对应的web容器。
