Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The annotation @EnableSpringDataWebSupport does not work with WebMvcConfigurationSupport?

I had been using the WebMvcConfigurerAdapter for a while. Since i could not get all the registered interceptors with the method getInterceptors(), i have switched to WebMvcConfigurationSupport, which has lot of default registered Spring Beans like ContentNegotiationManager, ExceptionHandlerExceptionResolver usw.

Now i have realised that, the very handy DomainClassConverter (which converts the domain class ids to domain class objects by using a CrudRepository) is not registered by default, although i use the annotation @EnableSpringDataWebSupport on my WebConfig class.

When i define this bean explicitly like this, it works then.

@EnableSpringDataWebSupport
@Configuration
public class WebConfig extends WebMvcConfigurationSupport {
    @Bean
    public DomainClassConverter<?> domainClassConverter() {
        return new DomainClassConverter<FormattingConversionService>(mvcConversionService());
    }
}

But why EnableSpringDataWebSupport does not work with WebMvcConfigurationSupport?

like image 514
akcasoy Avatar asked Oct 19 '22 21:10

akcasoy


1 Answers

It looks like configuration classes that extend WebMvcConfigurationSupport directly suffer from SPR-10565. The solution, at least for me, is to extend from DelegatingWebMvcConfiguration instead.

If you're overriding individual callbacks in your configuration class you'll likely want to call the superclass' implementation of the callback as well to ensure it's all handled correctly.

like image 188
kylesm Avatar answered Nov 04 '22 19:11

kylesm