Skip to content

Commit

Permalink
Clarify the effect of @EnableWebMvc
Browse files Browse the repository at this point in the history
Closes gh-36506
  • Loading branch information
wilkinsona committed Aug 8, 2023
1 parent 8dec443 commit b978950
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Beans can be ordered if you need to apply a precedence.
[[web.servlet.spring-mvc.auto-configuration]]
==== Spring MVC Auto-configuration
Spring Boot provides auto-configuration for Spring MVC that works well with most applications.

The auto-configuration adds the following features on top of Spring's defaults:
It replaces the need for `@EnableWebMvc` and the two cannot be used together.
In addition to Spring MVC's defaults, the auto-configuration provides the following features:

* Inclusion of `ContentNegotiatingViewResolver` and `BeanNameViewResolver` beans.
* Support for serving static resources, including support for WebJars (covered <<features#web.servlet.spring-mvc.static-content,later in this document>>).
Expand All @@ -46,7 +46,8 @@ If you want to keep those Spring Boot MVC customizations and make more {spring-f

If you want to provide custom instances of `RequestMappingHandlerMapping`, `RequestMappingHandlerAdapter`, or `ExceptionHandlerExceptionResolver`, and still keep the Spring Boot MVC customizations, you can declare a bean of type `WebMvcRegistrations` and use it to provide custom instances of those components.

If you want to take complete control of Spring MVC, you can add your own `@Configuration` annotated with `@EnableWebMvc`, or alternatively add your own `@Configuration`-annotated `DelegatingWebMvcConfiguration` as described in the Javadoc of `@EnableWebMvc`.
If you do not want to use the auto-configuration and want to take complete control of Spring MVC, add your own `@Configuration` annotated with `@EnableWebMvc`.
Alternatively, add your own `@Configuration`-annotated `DelegatingWebMvcConfiguration` as described in the Javadoc of `@EnableWebMvc`.



Expand Down

1 comment on commit b978950

@sandipchitale
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this update.

I wish some mention of connection of how DelegatingWebMvcConfiguration consumes all beans of type WebMvcConfigurer via:

https://github.com/spring-projects/spring-framework/blob/c809fda4edc9a76562328cb6ed1db3f481ce52dc/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.java#L49

was included in the above discussion.

Please sign in to comment.