与其明天开始,不如现在行动!
SpringBoot的web开发能力是由SpringMVC提供的
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
引入自动配置autoconfigure
EnableAutoConfiguration
注解使用@Import({AutoConfigurationImportSelector.class})
批量导入组件
加载META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
文件中配置的所有组件
所有web自动配置类如下
org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration
org.springframework.boot.autoconfigure.web.embedded.EmbeddedWebServerFactoryCustomizerAutoConfiguration
=====以下是响应式web场景的自动配置类,和现在的没关系
org.springframework.boot.autoconfigure.web.reactive.HttpHandlerAutoConfiguration
org.springframework.boot.autoconfigure.web.reactive.ReactiveMultipartAutoConfiguration
org.springframework.boot.autoconfigure.web.reactive.ReactiveWebServerFactoryAutoConfiguration
org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration
org.springframework.boot.autoconfigure.web.reactive.WebSessionIdResolverAutoConfiguration
org.springframework.boot.autoconfigure.web.reactive.error.ErrorWebFluxAutoConfiguration
org.springframework.boot.autoconfigure.web.reactive.function.client.ClientHttpConnectorAutoConfiguration
org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration
========
org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration
org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration
org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration
org.springframework.boot.autoconfigure.web.servlet.HttpEncodingAutoConfiguration
org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration
org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration
配置类绑定了配置文件的一堆配置项
spring.mvc
开头spring.web
spring.server.multipart
server
(如:编码方式)ContentNegotiatingViewResolver
和BeeanNameViewResolver
组件,方便视图解析static
文件夹下即可直接访问Converter
、GenericConverter
和 Formatter
Bean组件,适配常见数据类型转换和格式化需求HttpMessageConverters
,方便返回JSON等数据类型MessageCodesResolver
,方便国际化及错误消息处理index.html
ConfigurableWebBindingInitializer
bean组件,实现消息处理、数据绑定、类型转化等功能本文中若是有出现的错误请在评论区或者私信指出,我再进行改正优化,如果文章对你有所帮助,请给博主一个宝贵的三连,感谢大家😘!!!