Failed to instantiate [org.springframework.data.do

2019-08-05 11:05发布

When I'm sending a request like getUserPlaces?page=0&size=5 I get this error:

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

My controller is:

@Controller
@EnableSpringDataWebSupport
public class UserController {
...
@RequestMapping(value = "/getUserPlaces", method = RequestMethod.POST)
public @ResponseBody List<PlaceDto> getUserPlaces(@RequestBody RoutePagingDto routeRequest, Pageable pageable) {
    return placeService.placeToPlaceDto(userService.getUserPlaces(pageable));
}

In my spring-context.xml I have them declared beans:

<beans:bean class="org.springframework.data.web.SortHandlerMethodArgumentResolver" />

<beans:bean class="org.springframework.data.web.PageableHandlerMethodArgumentResolver" />

What I'm missing?

1条回答
姐就是有狂的资本
2楼-- · 2019-08-05 11:51

Remove @EnableSpringDataWebSupport from UserController class and create WebConfig class with the following code

@Configuration
@EnableWebMvc
@EnableSpringDataWebSupport
public class WebConfig extends WebMvcConfigurationSupport {}
查看更多
登录 后发表回答