关于spring:Spring-ApplicationContext启动方式

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容器。

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理