Spring Boot provides auto-configuration for Spring MVC that works well with most applications.
(Spring Boot为Spring MVC提供了自动配置功能,对大多数应用程序都很适用。)

The auto-configuration adds the following features on top of Spring’s defaults:
(自动配置在Spring的默认基础上增加了以下功能)

  • Inclusion of ContentNegotiatingViewResolver and BeanNameViewResolver beans.

(内容协商视图解析器和BeanName视图解析器)

  • Support for serving static resources, including support for WebJars.

(静态资源,包括webjars,只需要放到默认的位置,就能使用了。)

  • Automatic registration of Converter,GenericConverter, and Formatterbeans.

(自动注册转换器、格式化器)

  • Support for HttpMessageConverters.

(支持 HttpMessageConverters ,用来配合内容协商理解原理)

  • Automatic registration of MessageCodesResolver.

(自动配置 MessageCodesResolver ,国际化用的)

  • Static index.html support.

(静态 index.html 支持)

  • Automatic use of a ConfigurableWebBindingInitializer bean.

(自动使用 ConfigurableWebBindingInitializer ,数据绑定器)

If you want to keep those Spring Boot MVC customizations and make moreMVC customizations(interceptors, formatters, view controllers, and other features), you can add your own@Configurationclass of typeWebMvcConfigurerbutwithout@EnableWebMvc.
(不要用 @EnableWebMvc 注解,使用 @Configuration + webMvcConfigurer 自定义规则)

If you want to provide custom instances ofRequestMappingHandlerMapping,RequestMappingHandlerAdapter, orExceptionHandlerExceptionResolver, and still keep the Spring Boot MVC customizations, you can declare a bean of typeWebMvcRegistrationsand use it to provide custom instances of those components.
(声明 WbMvcRegistrations 改变默认底层组件)

If you want to take complete control of Spring MVC, you can add your own@Configurationannotated with@EnableWebMvc, or alternatively add your own@Configuration-annotatedDelegatingWebMvcConfigurationas described in the Javadoc of@EnableWebMvc.
(使用 @ @EnableWebMvc + @Configuration + @DelegurationWebConfiguration 全面接管 Spring MVC)

官方文档位置

https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-spring-mvc-auto-configuration

image.png