Isolated Controller Test can't instantiate Pageable

前端 未结 3 1593
小鲜肉
小鲜肉 2020-12-10 01:01

I have a Spring MVC Controller which uses Pagination Support of Spring-Data:

@Controller
public class ModelController {

    private static final int DEFAULT         


        
3条回答
  •  误落风尘
    2020-12-10 01:29

    For spring boot simply adding the ArgumentResolvers solved for me:

    From code which triggered the error:

    this.mockMvc = MockMvcBuilders.standaloneSetup(weightGoalResource).build();
    

    To this, which works:

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

提交回复
热议问题