Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

89
Visualizações
EnableSpringDataWebSupport doesn't seem to work well with WebMvcConfigurerAdapter

I was successfully using @EnableSpringDataWebSupport in my Spring Boot app to enable pagination, sorting and stuff. However, at some point, I had to introduce a custom argument resolver and did it with Java config as follows:

@Configuration 
@EnableSpringDataWebSupport 
public class MvcConfig extends WebMvcConfigurerAdapter {

    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
        argumentResolvers.add(renamingProcessor());
    }

    @Bean
    protected RenamingProcessor renamingProcessor() {
        return new RenamingProcessor(true);
    } 
}

It made my new argument resolver work, however completely broke paging and other features, that were automatically configured by @EnableSpringDataWebSupport. I've tried switching WebMvcConfigurerAdapter to alternatives like DelegatingWebMvcConfiguration or WebMvcConfigurationSupport, but no luck -- pagination fails with the exception:

Failed to instantiate [org.springframework.data.domain.Pageable]: Specified class is an interface

I would appreciate any help or advice how to handle this issue. Similar questions didn't help a lot:

  • The annotation @EnableSpringDataWebSupport does not work with WebMvcConfigurationSupport?
  • Failed to instantiate Pageable bean
  • WebMvcConfigurerAdapter does not work
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

So, after some investigation, I figured out the solution (perhaps, not ideal one, but still working -- I'd still be happy to see the "right" resolution for the problem from Spring professionals). What I changed is switching from extends WebMvcConfigurerAdapter to extends HateoasAwareSpringDataWebConfiguration (since we're using HATEOAS). I also updated the overridden addArgumentResolvers and now my MvcConfig looks like this:

@Configuration
public class MvcConfig extends HateoasAwareSpringDataWebConfiguration {

    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
        super.addArgumentResolvers(argumentResolvers);
        argumentResolvers.add(renamingProcessor());
    }

    @Bean
    protected RenamingProcessor renamingProcessor() {
        return new RenamingProcessor(true);
    }
}

The issue with Pageable disappeared, and custom RenamingProcessor works like a charm.

Hope this answer will help someone who's facing similar issue.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda