首页 > 其他分享 >20220615 Servlet 相关的 Spring Boot 自动配置类

20220615 Servlet 相关的 Spring Boot 自动配置类

时间:2022-11-28 09:57:50浏览次数:46  
标签:Spring 20220615 boot Boot springframework Bean autoconfigure org Condition

自动配置类

Servlet 相关的匹配的自动配置类:

  1. org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration
  2. org.springframework.boot.autoconfigure.web.embedded.EmbeddedWebServerFactoryCustomizerAutoConfiguration
  3. org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration
  4. org.springframework.boot.autoconfigure.web.servlet.HttpEncodingAutoConfiguration
  5. org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration
  6. org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration
  7. org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration
  8. org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration
  9. org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration
  10. org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration

无关的匹配的自动配置类

  1. org.springframework.boot.autoconfigure.aop.AopAutoConfiguration
  2. org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration
  3. org.springframework.boot.autoconfigure.context.LifecycleAutoConfiguration
  4. org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration
  5. org.springframework.boot.autoconfigure.admin.SpringApplicationAdminJmxAutoConfiguration
  6. org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration
  7. org.springframework.boot.autoconfigure.websocket.servlet.WebSocketServletAutoConfiguration

相关的属性类

  • org.springframework.boot.autoconfigure.web.servlet.WebMvcProperties
    • spring.mvc
  • org.springframework.boot.autoconfigure.web.WebProperties
    • spring.web
  • org.springframework.boot.autoconfigure.web.ServerProperties
    • server
  • org.springframework.boot.autoconfigure.web.servlet.MultipartProperties
    • spring.servlet.multipart
  • org.springframework.boot.autoconfigure.task.TaskExecutionProperties
    • spring.task.execution

自动配置类中的 @Bean

DispatcherServletAutoConfiguration

DispatcherServletAutoConfiguration.DispatcherServletConfiguration

静态内部类

引入(@Import@Bean

  • DispatcherServlet dispatcherServlet
DispatcherServletAutoConfiguration.DispatcherServletRegistrationConfiguration

静态内部类

匹配(@Condition@Bean

  • DispatcherServletRegistrationBean dispatcherServletRegistration

EmbeddedWebServerFactoryCustomizerAutoConfiguration

EmbeddedWebServerFactoryCustomizerAutoConfiguration.TomcatWebServerFactoryCustomizerConfiguration

静态内部类

匹配(@Condition@Bean

  • TomcatWebServerFactoryCustomizer tomcatWebServerFactoryCustomizer

ErrorMvcAutoConfiguration

引入(@Import@Bean

  • ErrorPageCustomizer errorPageCustomizer

静态引入(@Import@Bean

  • PreserveErrorControllerTargetClassPostProcessor preserveErrorControllerTargetClassPostProcessor

匹配(@Condition@Bean

  • DefaultErrorAttributes errorAttributes
  • BasicErrorController basicErrorController
ErrorMvcAutoConfiguration.DefaultErrorViewResolverConfiguration

静态内部类

匹配(@Condition@Bean

  • DefaultErrorViewResolver conventionErrorViewResolver
ErrorMvcAutoConfiguration.WhitelabelErrorViewConfiguration

静态内部类

匹配(@Condition@Bean

  • @Bean(name = "error") View defaultErrorView
  • BeanNameViewResolver beanNameViewResolver

HttpEncodingAutoConfiguration

引入(@Import@Bean

  • LocaleCharsetMappingsCustomizer localeCharsetMappingsCustomizer

匹配(@Condition@Bean

  • CharacterEncodingFilter characterEncodingFilter

HttpMessageConvertersAutoConfiguration

匹配(@Condition@Bean

  • HttpMessageConverters messageConverters
HttpMessageConvertersAutoConfiguration.StringHttpMessageConverterConfiguration

匹配(@Condition@Bean

  • StringHttpMessageConverter stringHttpMessageConverter
JacksonHttpMessageConvertersConfiguration

引入的配置类

JacksonHttpMessageConvertersConfiguration.MappingJackson2HttpMessageConverterConfiguration

静态内部类

匹配(@Condition@Bean

  • MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter

MultipartAutoConfiguration

匹配(@Condition@Bean

  • MultipartConfigElement multipartConfigElement
  • StandardServletMultipartResolver multipartResolver

RestTemplateAutoConfiguration

匹配(@Condition@Lazy @Bean

  • RestTemplateBuilderConfigurer restTemplateBuilderConfigurer
  • RestTemplateBuilder restTemplateBuilder

ServletWebServerFactoryAutoConfiguration

引入(@Import@Bean

  • ServletWebServerFactoryCustomizer servletWebServerFactoryCustomizer

匹配(@Condition@Bean

  • TomcatServletWebServerFactoryCustomizer tomcatServletWebServerFactoryCustomizer
ServletWebServerFactoryAutoConfiguration.BeanPostProcessorsRegistrar

引入的 ImportBeanDefinitionRegistrar

  • webServerFactoryCustomizerBeanPostProcessor
    • WebServerFactoryCustomizerBeanPostProcessor
  • errorPageRegistrarBeanPostProcessor
    • ErrorPageRegistrarBeanPostProcessor
ServletWebServerFactoryConfiguration.EmbeddedTomcat

引入的配置类

  • TomcatServletWebServerFactory tomcatServletWebServerFactory

TaskExecutionAutoConfiguration

匹配(@Condition@Bean

  • TaskExecutorBuilder taskExecutorBuilder
  • ThreadPoolTaskExecutor applicationTaskExecutor

WebMvcAutoConfiguration

匹配(@Condition@Bean

  • OrderedFormContentFilter formContentFilter
WebMvcAutoConfiguration.EnableWebMvcConfiguration

静态内部类

继承 WebMvcConfigurationSupport :这是提供 MVC Java 配置背后的配置的主类。它通常通过将 @EnableWebMvc 添加到应用程序 @Configuration 类来导入。另一种更高级的选择是直接从此类扩展并根据需要覆盖方法,记住将 @Configuration 添加到子类,将 @Bean 添加到覆盖的 @Bean 方法。

引入(@Import@Bean

  • WelcomePageHandlerMapping welcomePageHandlerMapping

引入父类 WebMvcConfigurationSupport @Bean 方法

  • PathPatternParser mvcPatternParser
  • UrlPathHelper mvcUrlPathHelper
  • PathMatcher mvcPathMatcher
  • HandlerMapping viewControllerHandlerMapping
  • BeanNameUrlHandlerMapping beanNameHandlerMapping
  • RouterFunctionMapping routerFunctionMapping
  • HandlerMapping resourceHandlerMapping
  • ResourceUrlProvider mvcResourceUrlProvider
  • HandlerMapping defaultServletHandlerMapping
  • HandlerFunctionAdapter handlerFunctionAdapter
  • CompositeUriComponentsContributor mvcUriComponentsContributor
  • HttpRequestHandlerAdapter httpRequestHandlerAdapter
  • SimpleControllerHandlerAdapter simpleControllerHandlerAdapter
  • HandlerExceptionResolver handlerExceptionResolver
  • ViewResolver mvcViewResolver
  • HandlerMappingIntrospector mvcHandlerMappingIntrospector
  • RequestToViewNameTranslator viewNameTranslator

重写父类 WebMvcConfigurationSupport @Bean 方法

  • RequestMappingHandlerAdapter requestMappingHandlerAdapter
  • RequestMappingHandlerMapping requestMappingHandlerMapping
  • FormattingConversionService mvcConversionService
  • Validator mvcValidator
  • ContentNegotiationManager mvcContentNegotiationManager
  • LocaleResolver localeResolver
  • ThemeResolver themeResolver
  • FlashMapManager flashMapManager
WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter

静态内部类

匹配(@Condition@Bean

  • InternalResourceViewResolver defaultViewResolver
  • RequestContextFilter requestContextFilter
  • ContentNegotiatingViewResolver viewResolver

部分不匹配的配置类和 @Bean

下面存在不匹配方法的都是匹配的配置类,不存在不匹配方法的配置类都不匹配

  • ServletWebServerFactoryAutoConfiguration.ForwardedHeaderFilterConfiguration
  • DispatcherServletAutoConfiguration.DispatcherServletConfiguration
    • MultipartResolver multipartResolver
  • ServletWebServerFactoryConfiguration.EmbeddedJetty
  • ServletWebServerFactoryConfiguration.EmbeddedUndertow
  • TaskSchedulingAutoConfiguration
    • ThreadPoolTaskScheduler taskScheduler
  • ValidationAutoConfiguration
  • WebMvcAutoConfiguration
    • OrderedHiddenHttpMethodFilter hiddenHttpMethodFilter
  • WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter
    • BeanNameViewResolver beanNameViewResolver

标签:Spring,20220615,boot,Boot,springframework,Bean,autoconfigure,org,Condition
From: https://www.cnblogs.com/huangwenjie/p/16931392.html

相关文章

  • 20220704 Spring 相关
    @Configuration(proxyBeanMethods=false)的作用默认proxyBeanMethods=true,会为配置类生成CGLIB代理类。注意,不是为定义的@Bean生成代理类。如果在@Bean方法......
  • Spring Scheduled 三种定时方式
    SpringSchedule配置时间的三种方式fixRate:间隔时间,会根据首次执行时间预先安排固定的时间,错过立即执行fixDelay:间隔时间,上次结束时间后多少间隔后执行cron:指定......
  • springCloud将http请求网关更改为https请求
    如果需要将http请求换成https请求,大致需要三步。第一步:生成证书。网上有很多通过阿里云生成证书的教程。也有通过JDK生成证书。在jdk目录打开命令窗口,执行一下命令:keytoo......
  • SpringBoot整合MybatisPlus实现分页功能
    首先,展示一下项目的主题:  创建数据库,放入一些数据,方便我们接下来的功能演示: 接下来,我们创建一个实体类,然后写对应的接口:packagecom.example.domain;importlo......
  • SpringSecurity从入门到精通
    0.简介SpringSecurity和Shiro比较。中大型的项目都是使用SpringSecurity做安全框架,小项目使用Shiro比较多,因为它比SpringSecurity上手更加简单认证与授权:认证:验证......
  • springBoot 过滤器去除请求参数前后空格(附源码)
    背景:用户在前端页面中不小心输入的前后空格,为了防止因为前后空格原因引起业务异常,所以我们需要去除参数的前后空格!如果我们手动去除参数前后空格,我们可以这样做@......
  • SpringBoot(四):java从配置文件中取值的方式
    一、SpringBoot项目中取yaml配置文件中的值application.yamltest:url:localhost:8080name:rootpassword:123456val:a:1b:2c:3TestC......
  • SpringBoot17(项目部署)
    一、大纲二、操作过程1-(启一个web项目,已经配置好Maven的,按图片步骤点击package)2-(如果打包成功后的效果,Maven一定要配置好)2.1-Bulidingjar:打包后jar包的"位置/路径......
  • Spring Security(6)
    您好,我是湘王,这是我的51CTO博客,欢迎您来,欢迎您再来~Spring Security使用MySQL保存cookie记录虽然方便,但是目前更多的主流互联网应用都是用NoSQL来保存非业务数据的,SpringSe......
  • Spring Security(6)
    您好,我是湘王,这是我的博客园,欢迎您来,欢迎您再来~ Spring Security使用MySQL保存cookie记录虽然方便,但是目前更多的主流互联网应用都是用NoSQL来保存非业务数据的,Spring......