Failed to instantiate Pageable bean

The easiest way to get this working is to set @EnableSpringDataWebSupport in your configuration. Alternatively, in a pure XML based configuration, declare SpringDataWebConfiguration as Spring bean.

That will make sure the necessary HandlerMethodArgumentResolver will be registered correctly.


Add the following to you're test class:

@Inject
private PageableHandlerMethodArgumentResolver pageableArgumentResolver;

PageableHandlerMethodArgumentResolver

and configure it during MockMvc setup:

@Before
public void setup() {
    ...
    this.mockMvc = MockMvcBuilders.standaloneSetup(resource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .build();
}

just to add on to Tom Van Rossom's reply, if you use @RunWith(MockitoJUnitRunner.class), you can create an instance of PageableHandlerMethodArgumentResolver when you initialize the mockMvc (like what Loren mentioned).Eg

mockMvc = MockMvcBuilders.standaloneSetup(restController)
            .setCustomArgumentResolvers(new PageableHandlerMethodArgumentResolver())
            .build();