diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfiguration.java index 1ea91f945d0a..b80e28fbe42b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfiguration.java @@ -211,7 +211,7 @@ private void customizeResourceHandlerRegistration( /** * Configuration equivalent to {@code @EnableWebFlux}. */ - @Configuration + @Configuration(proxyBeanMethods = false) public static class EnableWebFluxConfiguration extends DelegatingWebFluxConfiguration { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java index c2511c61cff3..cbda523fa81d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java @@ -119,6 +119,7 @@ import org.springframework.web.servlet.resource.EncodedResourceResolver; import org.springframework.web.servlet.resource.ResourceHttpRequestHandler; import org.springframework.web.servlet.resource.ResourceResolver; +import org.springframework.web.servlet.resource.ResourceUrlProvider; import org.springframework.web.servlet.resource.VersionResourceResolver; import org.springframework.web.servlet.view.BeanNameViewResolver; import org.springframework.web.servlet.view.ContentNegotiatingViewResolver; @@ -466,7 +467,7 @@ static final class FaviconRequestHandler extends ResourceHttpRequestHandler { /** * Configuration equivalent to {@code @EnableWebMvc}. */ - @Configuration + @Configuration(proxyBeanMethods = false) public static class EnableWebMvcConfiguration extends DelegatingWebMvcConfiguration { private final WebMvcProperties mvcProperties; @@ -486,8 +487,12 @@ public EnableWebMvcConfiguration( @Bean @Override - public RequestMappingHandlerAdapter requestMappingHandlerAdapter() { - RequestMappingHandlerAdapter adapter = super.requestMappingHandlerAdapter(); + public RequestMappingHandlerAdapter requestMappingHandlerAdapter( + ContentNegotiationManager mvcContentNegotiationManager, + FormattingConversionService mvcConversionService, + Validator mvcValidator) { + RequestMappingHandlerAdapter adapter = super.requestMappingHandlerAdapter( + mvcContentNegotiationManager, mvcConversionService, mvcValidator); adapter.setIgnoreDefaultModelOnRedirect(this.mvcProperties == null || this.mvcProperties.isIgnoreDefaultModelOnRedirect()); return adapter; @@ -505,9 +510,13 @@ protected RequestMappingHandlerAdapter createRequestMappingHandlerAdapter() { @Bean @Primary @Override - public RequestMappingHandlerMapping requestMappingHandlerMapping() { + public RequestMappingHandlerMapping requestMappingHandlerMapping( + ContentNegotiationManager mvcContentNegotiationManager, + FormattingConversionService mvcConversionService, + ResourceUrlProvider mvcResourceUrlProvider) { // Must be @Primary for MvcUriComponentsBuilder to work - return super.requestMappingHandlerMapping(); + return super.requestMappingHandlerMapping(mvcContentNegotiationManager, + mvcConversionService, mvcResourceUrlProvider); } @Bean @@ -539,12 +548,15 @@ protected RequestMappingHandlerMapping createRequestMappingHandlerMapping() { } @Override - protected ConfigurableWebBindingInitializer getConfigurableWebBindingInitializer() { + protected ConfigurableWebBindingInitializer getConfigurableWebBindingInitializer( + FormattingConversionService mvcConversionService, + Validator mvcValidator) { try { return this.beanFactory.getBean(ConfigurableWebBindingInitializer.class); } catch (NoSuchBeanDefinitionException ex) { - return super.getConfigurableWebBindingInitializer(); + return super.getConfigurableWebBindingInitializer(mvcConversionService, + mvcValidator); } } @@ -558,12 +570,9 @@ protected ExceptionHandlerExceptionResolver createExceptionHandlerExceptionResol } @Override - protected void configureHandlerExceptionResolvers( + protected void extendHandlerExceptionResolvers( List exceptionResolvers) { - super.configureHandlerExceptionResolvers(exceptionResolvers); - if (exceptionResolvers.isEmpty()) { - addDefaultHandlerExceptionResolvers(exceptionResolvers); - } + super.extendHandlerExceptionResolvers(exceptionResolvers); if (this.mvcProperties.isLogResolvedException()) { for (HandlerExceptionResolver resolver : exceptionResolvers) { if (resolver instanceof AbstractHandlerExceptionResolver) {