未能实例[org.springframework.data.domain.Pageable]:指定的

2019-10-21 18:08发布

当我送样要求getUserPlaces?page=0&size=5我得到这个错误:

未能实例[org.springframework.data.domain.Pageable]:指定的类是一个接口

我的控制器是:

@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));
}

在我的弹簧的context.xml我有他们宣称豆:

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

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

什么我失踪?

Answer 1:

删除@EnableSpringDataWebSupport从UserController类,并用下面的代码创建WebConfig类

@Configuration
@EnableWebMvc
@EnableSpringDataWebSupport
public class WebConfig extends WebMvcConfigurationSupport {}


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