首先,一共有三种类型AnnotationConfigServletWebServerApplicationContext,AnnotationConfigReactiveWebServerApplicationContext,AnnotationConfigApplicationContext。
springboot会根据webApplicationType的值来确定你加载哪一个applicationContext
/** * Strategy method used to create the {@link ApplicationContext}. By default this * method will respect any explicitly set application context or application context * class before falling back to a suitable default. * @return the application context (not yet refreshed) * @see #setApplicationContextClass(Class) */ protected ConfigurableApplicationContext createApplicationContext() { Class<?> contextClass = this.applicationContextClass; if (contextClass == null) { try { switch (this.webApplicationType) { case SERVLET: contextClass = Class.forName(DEFAULT_SERVLET_WEB_CONTEXT_CLASS);//DEFAULT_SERVLET_WEB_CONTEXT_CLASS="org.springframework.boot."+ "web.servlet.context.AnnotationConfigServletWebServerApplicationContext" break; case REACTIVE: contextClass = Class.forName(DEFAULT_REACTIVE_WEB_CONTEXT_CLASS);//DEFAULT_REACTIVE_WEB_CONTEXT_CLASS="org.springframe