Avoid bean method proxying in WebMVC and WebFlux config
This commit applies changes similar to what's been done in gh-9068, for MVC and WebFlux configurations. This is now possible thanks to the changes done in Spring Framework in https://github.com/spring-projects/spring-framework/pull/22596 Fixes gh-16427
This commit is contained in:
parent
edb5937571
commit
f221061d81
|
@ -211,7 +211,7 @@ public class WebFluxAutoConfiguration {
|
|||
/**
|
||||
* Configuration equivalent to {@code @EnableWebFlux}.
|
||||
*/
|
||||
@Configuration
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public static class EnableWebFluxConfiguration
|
||||
extends DelegatingWebFluxConfiguration {
|
||||
|
||||
|
|
|
@ -119,6 +119,7 @@ import org.springframework.web.servlet.resource.AppCacheManifestTransformer;
|
|||
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 @@ public class WebMvcAutoConfiguration {
|
|||
/**
|
||||
* Configuration equivalent to {@code @EnableWebMvc}.
|
||||
*/
|
||||
@Configuration
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public static class EnableWebMvcConfiguration extends DelegatingWebMvcConfiguration {
|
||||
|
||||
private final WebMvcProperties mvcProperties;
|
||||
|
@ -486,8 +487,12 @@ public class WebMvcAutoConfiguration {
|
|||
|
||||
@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 @@ public class WebMvcAutoConfiguration {
|
|||
@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 @@ public class WebMvcAutoConfiguration {
|
|||
}
|
||||
|
||||
@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 @@ public class WebMvcAutoConfiguration {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void configureHandlerExceptionResolvers(
|
||||
protected void extendHandlerExceptionResolvers(
|
||||
List<HandlerExceptionResolver> exceptionResolvers) {
|
||||
super.configureHandlerExceptionResolvers(exceptionResolvers);
|
||||
if (exceptionResolvers.isEmpty()) {
|
||||
addDefaultHandlerExceptionResolvers(exceptionResolvers);
|
||||
}
|
||||
super.extendHandlerExceptionResolvers(exceptionResolvers);
|
||||
if (this.mvcProperties.isLogResolvedException()) {
|
||||
for (HandlerExceptionResolver resolver : exceptionResolvers) {
|
||||
if (resolver instanceof AbstractHandlerExceptionResolver) {
|
||||
|
|
Loading…
Reference in New Issue