简体   繁体   English

无法实例化[org.springframework.data.domain.Pageable]:指定的类是接口

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

When I'm sending a request like getUserPlaces?page=0&size=5 I get this error: 当我发送类似getUserPlaces?page=0&size=5类的请求时,出现此错误:

Failed to instantiate [org.springframework.data.domain.Pageable]: Specified class is an interface 无法实例化[org.springframework.data.domain.Pageable]:指定的类是接口

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: 在我的spring-context.xml中,我将它们声明为bean:

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

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

What I'm missing? 我想念的是什么?

Remove @EnableSpringDataWebSupport from UserController class and create WebConfig class with the following code 从UserController类中删除@EnableSpringDataWebSupport ,并使用以下代码创建WebConfig类

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到接口 org.springframework.data.domain.Pageable 的主要或默认构造函数 - No primary or default constructor found for interface org.springframework.data.domain.Pageable org.springframework.beans.BeanInstantiationException:无法实例化[org.springframework.ui.Model]:指定的类是接口 - org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ui.Model]: Specified class is an interface 无法实例化UriInfo指定的类是接口 - Failed to instantiate UriInfo Specified class is an interface org.springframework.data.domain.PageImpl 无法反序列化,当我想使用带有注释 @Cacheable(spring cache) 的 findAll(Pageable pageable) 时? - org.springframework.data.domain.PageImpl can't be deserialized,when i want to use findAll(Pageable pageable) with annotation @Cacheable(spring cache)? Spring Boot WebFluxTest 测试,无法实例化存储库,指定类为接口 - Spring Boot WebFluxTest test, failed to instantiate repository, specified class is an interface 带有SpringBoot的GraphQLTester无法实例化xxx指定的class是一个接口 - GraphQLTester with SpringBoot Failed to instantiate xxx specified class is an interface 无法实例化Pageable bean - Failed to instantiate Pageable bean bean 实例化失败; 嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 bean 类 - Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class org.springframework.data.mapping.model.MappingInstantiationException:无法使用新的布尔字段实例化对象 - org.springframework.data.mapping.model.MappingInstantiationException: Failed to instantiate object with new boolean field 无法实例化 [org.springframework.web.reactive.function.client.WebClient] - Failed to instantiate [org.springframework.web.reactive.function.client.WebClient]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM