Affects: 2.1.4.RELEASE
I'm trying to extend org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration.EnableWebMvcConfiguration
which is titled as configuration equivalent to @EnableWebMvc
I need to edit this specific configuration due to a problem with request mapping in combination with feign.
But when I extend the class I get an exception:
Caused by: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'requestMappingHandlerAdapter'
And the requestMappingHandlerAdapter is beeing overridden in WebMvcAutoConfiguration.EnableWebMvcConfiguration:
@Bean
@Override
public RequestMappingHandlerAdapter requestMappingHandlerAdapter() {
RequestMappingHandlerAdapter adapter = super.requestMappingHandlerAdapter();
adapter.setIgnoreDefaultModelOnRedirect(this.mvcProperties == null
|| this.mvcProperties.isIgnoreDefaultModelOnRedirect());
return adapter;
}
which is a Bean defined in WebMvcConfigurationSupport, which is extended by DelegatingWebMvcConfiguration:
@Bean
public RequestMappingHandlerAdapter requestMappingHandlerAdapter()
A workaround would be to add the configuration
spring.main.allow-bean-definition-overriding: true
but i guess that this should be reported as a bug.
Comment From: snicoll
I'm trying to extend org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration.EnableWebMvcConfiguration
You shouldn't be doing that. Auto-configuration classes are not public API. I believe this wouldn't work with recent versions anyway. If you need a way to tune something, please open a request for enhancement in Spring Boot.