This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Framework 6.0.26! |
Advanced Java Config
@EnableWebMvc
imports DelegatingWebMvcConfiguration
, which:
-
Provides default Spring configuration for Spring MVC applications
-
Detects and delegates to
WebMvcConfigurer
implementations to customize that configuration.
For advanced mode, you can remove @EnableWebMvc
and extend directly from
DelegatingWebMvcConfiguration
instead of implementing WebMvcConfigurer
,
as the following example shows:
-
Java
-
Kotlin
@Configuration
public class WebConfig extends DelegatingWebMvcConfiguration {
// ...
}
@Configuration
class WebConfig : DelegatingWebMvcConfiguration() {
// ...
}
You can keep existing methods in WebConfig
, but you can now also override bean declarations
from the base class, and you can still have any number of other WebMvcConfigurer
implementations on
the classpath.