首页
学习
活动
专区
工具
TVP
发布

springboot中WebMvcConfigurationSupport、WebMvcConfigurationAdapter区别

2、@EnableWebMvc、WebMvcConfigurationSupport、WebMvcConfigurationAdapter @EnableWebMvc=WebMvcConfigurationSupport...,使用了@EnableWebMvc注解等于扩展了WebMvcConfigurationSupport但是没有重写任何方法 @EnableWebMvc+extends WebMvcConfigurationAdapter...,在扩展的类中重写父类的方法即可,这种方式会屏蔽springboot的WebMvcAutoConfiguration中的设置 @EnableWebMvc+extends WebMvcConfigurationSupport...只会使用@EnableWebMvc extends WebMvcConfigurationSupport,在扩展的类中重写父类的方法即可,这种方式会屏蔽springboot的@WebMvcAutoConfiguration...)说明,当没有WebMvcConfigurationSupport对应的bean时,才会使用该配置,所以当我们使用继承WebMvcConfigurationSupport的方式类扩展mvc时,原有的配置则无效

2.7K30
您找到你想要的搜索结果了吗?
是的
没有找到

Spring Boot 中自定义 SpringMVC 配置,到底继承谁?

WebMvcConfigurationSupport 前面两个都好理解,还有一个 WebMvcConfigurationSupport ,这个又是干什么用的呢?...那么在这里我自定义 SpringMVC 配置的时候,就是通过继承 WebMvcConfigurationSupport 类来实现的。...在 WebMvcConfigurationSupport 类中,提供了用 Java 配置 SpringMVC 所需要的所有方法。我们来看一下这个方法的摘要: ?...在这里首先大家需要明确的是,WebMvcConfigurationSupport 类本身是没有问题的,我们自定义 SpringMVC 的配置是可以通过继承 WebMvcConfigurationSupport...换句话说,在纯 Java 配置的 SSM 中,如果你需要自定义 SpringMVC 配置,你离不开 WebMvcConfigurationSupport ,所以在这种情况下建议通过继承 WebMvcConfigurationSupport

61530

Spring Boot2 系列教程(十八)Spring Boot 中自定义 SpringMVC 配置

WebMvcConfigurationSupport 前面两个都好理解,还有一个 WebMvcConfigurationSupport ,这个又是干什么用的呢?...那么在这里我自定义 SpringMVC 配置的时候,就是通过继承 WebMvcConfigurationSupport 类来实现的。...在 WebMvcConfigurationSupport 类中,提供了用 Java 配置 SpringMVC 所需要的所有方法。我们来看一下这个方法的摘要: ?...在这里首先大家需要明确的是,WebMvcConfigurationSupport 类本身是没有问题的,我们自定义 SpringMVC 的配置是可以通过继承 WebMvcConfigurationSupport...换句话说,在纯 Java 配置的 SSM 中,如果你需要自定义 SpringMVC 配置,你离不开 WebMvcConfigurationSupport ,所以在这种情况下建议通过继承 WebMvcConfigurationSupport

41720

Spring Boot 静态资源处理

但是如果你想要自己配置一些项目的设置,你可以在@Configuration注解的配置类上增加@EnableWebMvc或者继承WebMvcConfigurationSupport和WebMvcConfigurationAdapter...正文: 首先解析@EnableWebMvc 、WebMvcConfigurationSupport和WebMvcConfigurerAdapter # 在spring-boot+spring mvc...首先,@EnableWebMvc=WebMvcConfigurationSupport,使用了@EnableWebMvc注解等于扩展了WebMvcConfigurationSupport但是没有重写任何方法...extends WebMvcConfigurerAdapter,在扩展的类中重写父类的方法即可,这种方式会屏蔽springboot的@EnableAutoConfiguration中的设置 extends WebMvcConfigurationSupport...WebMvcConfigurerAdapter,在扩展的类中重写父类的方法即可,这种方式依旧使用springboot的@EnableAutoConfiguration中的设置 具体哪种方法适合,看个人对于项目的需求和要把控的程度,在WebMvcConfigurationSupport

1.6K60

SpringMVC源码学习(四)- SpringBoot的整合你真的会吗?

如上图所示,这个WebAutoConfiguration会在类级别注解扫描的时候被扫描到,但是它和webmvcConfigurationSupport是不兼容的,所以这个类只对WebMvcConfigurer...---- 那么如果我们直接继承WebMvcConfigurationSupport会怎样? 首先我们要知道我们的AutoWebMvcConfiguration是不会起作用了。...但是我们发现WebMvcConfigurationSupport中有很多@Bean的注解,意思就是说只要我们的自定义类上具有@Configuration注解就可以独善其身了。...毕竟WebMvcConfigurationSupport里包含了很多组件。直接用就好了。当然如果我们需要自定义的话就得重写,当然必须要对一些组件特别了解,否则可能会出问题。...第二种方式是继承WebMvcConfigurationSupport,因为WebMvcConfigurationSupport包含了很多@Bean的对Spring注册,所以可以直接使用,但对于比较复杂的方法重写上需要足够的了解才可以

35530

一波带走,教你Spring Boot如何扩展、接管MVC?

在这里需要声明一个前提:**配置类上没有标注@EnableWebMvc并且没有任何一个配置类继承了WebMvcConfigurationSupport**。至于具体原因,下文会详细解释。...{} 明白了,@EnableWebMvc这个注解实际上就是导入了一个WebMvcConfigurationSupport子类型的配置类而已。...而WEB模块的自动配置类有这么一行注解@ConditionalOnMissingBean(WebMvcConfigurationSupport.class),源码如下: @Configuration(proxyBeanMethods...一切都已经揭晓了,@EnableWebMvc导入了一个WebMvcConfigurationSupport类型的配置类,导致了自动配置类WebMvcAutoConfiguration标注的@@ConditionalOnMissingBean...(WebMvcConfigurationSupport.class)判断为false了,从而自动配置类失效了。

17330

Spring 全家桶之 Spring Boot 2.6.4(五)- WebMvcAutoConfiguration(Part D)

会导致所有自动配置全部失效 @EnableWebMvc导入了一个DelegatringWebMvcConfiguration类 图片 DelegatringWebMvcConfiguration又继承了WebMvcConfigurationSupport...图片 再回来看WebMvcAutoConfiguration自动配置类上标注了条件注解 @ConditionalOnMissingBean(WebMvcConfigurationSupport.class...)也就是说,只有在WebMvcConfigurationSupport不在容器中时才会将自动配置类导入容器中。...@EnableWebMvc注解往容器中导入了一个WebMvcConfigurationSupport的子类DelegatringWebMvcConfiguration,这就会导致WebMvcAutoConfiguration...不会导入到容器中,当然也就无法发挥自动配置的作用了 图片 而@EnableWebMvc注解导入的WebMvcConfigurationSupport的子类DelegatringWebMvcConfiguration

64210
领券