dineshonjava

WebMvcConfigurerAdapter vs WebMvcConfigurationSupport in Spring MVC

In this tutorial, we will discuss about difference between webmvcconfigureradapter vs webmvcconfigurationsupport. These both classes are related to Spring MVC java based configuration. It is actually simplified web configuration with Spring in the web application. Let's see some differences between of these two classes.


WebMvcConfigurerAdapter vs WebMvcConfigurationCupport

WebMvcConfigurationSupport WebMvcConfigurerAdapter
In the Spring MVC framework, this is the main class providing the configuration behind the MVC Java config. This is simple adapter class for customizing some of the default configuration.
We could use the @EnableWebMvc annotation to import the configuration of this class automatically. This is not related to the @EnableWebMvc annotation.
We could extend WebMvcConfigurationSupport class to prevent the default configuration imported by the @EnableWebMvc annotation. We could extend WebMvcConfigurerAdapter class to customize some of the default configuration imported by @EnableWebMvc annotation.
In the java configuration file for spring mvc either we could use @EnableWebMvc annotation or extend WebMvcConfigurationSupport class. If we are extending this class, still required to use @EnableWebMvc annotation, otherwise application will not work.