回到WebMvcAutoConfiguration类
@Configuration(proxyBeanMethods = false) @ConditionalOnWebApplication(type = Type.SERVLET) @ConditionalOnClass({ Servlet.class, DispatcherServlet.class, WebMvcConfigurer.class }) @ConditionalOnMissingBean(WebMvcConfigurationSupport.class) @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE + 10) @AutoConfigureAfter({ DispatcherServletAutoConfiguration.class, TaskExecutionAutoConfiguration.class, ValidationAutoConfiguration.class }) public class WebMvcAutoConfiguration {}
注意看第四行--->@ConditionalOnMissingBean(WebMvcConfigurationSupport.class)
这是一个条件判断,没有WebMvcConfigurationSupport类才能让本类生效
一旦使用@EnableWebMvc,就会使其生效,从而让SpringBoot有关webMVC的自动配置失效