Skip to content

Commit

Permalink
Merge branch '3.0.x' into 3.1.x
Browse files Browse the repository at this point in the history
Closes gh-38018
  • Loading branch information
wilkinsona committed Oct 25, 2023
2 parents b764192 + b33ee84 commit 4faabcf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,7 @@
package org.springframework.boot.autoconfigure.web.servlet;

import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
Expand All @@ -25,9 +26,12 @@
* Interface to register key components of the {@link WebMvcConfigurationSupport} in place
* of the default ones provided by Spring MVC.
* <p>
* All custom instances are later processed by Boot and Spring MVC configurations. A
* single instance of this component should be registered, otherwise making it impossible
* to choose from redundant MVC components.
* All custom instances are later processed by Boot and Spring MVC configurations. To
* participate in, and if desired, override that subsequent processing,
* {@link WebMvcConfigurer} should be used.
* <p>
* A single instance of this component should be registered, otherwise making it
* impossible to choose from redundant MVC components.
*
* @author Brian Clozel
* @since 2.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ In addition to Spring MVC's defaults, the auto-configuration provides the follow
If you want to keep those Spring Boot MVC customizations and make more {spring-framework-docs}/web.html#mvc[MVC customizations] (interceptors, formatters, view controllers, and other features), you can add your own `@Configuration` class of type `WebMvcConfigurer` but *without* `@EnableWebMvc`.

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.
The custom instances will be subject to further initialization and configuration by Spring MVC.
To participate in, and if desired, override that subsequent processing, a `WebMvcConfigurer` should be used.

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

0 comments on commit 4faabcf

Please sign in to comment.