原文:http://pimin.net/archives/432

环境:Eclipse LUNA、Spring 4.1.1、或Spring 4.3.3、Spring Data Elasticsearch 1.1.0

缘由:在调试Spring Data Elasticsearch的时候,希望在查询的时候实现分页查询。传统的方式就是在Controller的参数表中自己获取分页信息,然后组装成Pageable。在Spring Data Elasticsearch官方文档介绍有两种自动化方案:

1、使用<bean class=”org.springframework.data.web.config.SpringDataWebConfiguration” />

官方介绍说可以注册DomainClassConverter和HandlerMethodArgumentResolver。

2、配置org.springframework.data.web.PageableHandlerMethodArgumentResolver

<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="customArgumentResolvers">
<list>
<bean class="org.springframework.data.web.PageableHandlerMethodArgumentResolver" />
</list>
</property>
</bean>

很遗憾,使用这两种方法后直接报错:

org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

解决方案,那就是在web-context.xml加入下面的代码

<mvc:annotation-driven>
<mvc:argument-resolvers>
<bean class="org.springframework.data.web.PageableHandlerMethodArgumentResolver" />
</mvc:argument-resolvers>
</mvc:annotation-driven>
 

Could not instantiate bean class [org.springframework.data.domain.Pageable]: Specified class is an interface解决方案的更多相关文章

  1. Could not instantiate bean class [org.springframework.data.mongodb.core.MongoTemplate]

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'repositoryDa ...

  2. springmvc上传文件报错org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.web.multipart.MultipartFile]

    在用springmvc+mybatis进行项目开发时,上传文件抛异常... org.springframework.beans.BeanInstantiationException: Could no ...

  3. Could not instantiate bean class [org.springframework.web.multipart.MultipartFile]: Specified class

    如果在使用SpringMVC中使用文件上传的MultipartFile对象时,出现了以下的错误: Could not instantiate bean class [org.springframewo ...

  4. org.springframework.data.mapping.PropertyReferenceException: No property created found for type

    错误原因:org.springframework.data.domain.SortSort sort=new Sort(Sort.Direction.DESC,"created_time&q ...

  5. Consider defining a bean of type 'org.springframework.data.redis.connection.RedisConnectionFactory' in your configuration

    Description: Parameter 0 of method redisTemplate in com.liaojie.cloud.auth.server.config.redis.Redis ...

  6. SpringBoot- springboot集成Redis出现报错:No qualifying bean of type 'org.springframework.data.redis.connection.RedisConnectionFactory'

    Springboot将accessToke写入Redisk 缓存,springboot集成Redis出现报错 No qualifying bean of type 'org.springframewo ...

  7. Field redisTemplate in xxxxxx required a bean of type 'org.springframework.data.redis.core.RedisTemplate' that could not be found.

    *************************** APPLICATION FAILED TO START *************************** Description: Fie ...

  8. Parameter 0 of method redisTemplate in org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration required a bean of type 'org.springframework.data.redis.connection.RedisConnectionFactor

    Error starting ApplicationContext. To display the conditions report re-run your application with 'de ...

  9. org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.hs.model.StudentModel]: No default constructor found; nested exception is java.lang.NoSuchMethodException: c

    root cause org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [c ...

随机推荐

  1. php多虚拟主机配置

    一.配置httpd.conf# Virtual hosts#Include conf/extra/httpd-vhosts.conf       //取消这一行的# 二.配置httpd-vhosts. ...

  2. [Leetcode Week4]Merge Two Sorted Lists

    Merge Two Sorted Lists题解 原创文章,拒绝转载 题目来源:https://leetcode.com/problems/merge-two-sorted-lists/descrip ...

  3. c 語言 控制碼

    source code #include <stdio.h> int main() { char *test = "ABC\x41\n"; printf("s ...

  4. swoole扩展安装

    1Swoole扩展的编译安装 Swoole扩展是按照php标准扩展构建的.使用phpize来生成php编译配置,./configure来做编译配置检测,make和make install来完成安装. ...

  5. 【 Linux 】Keepalived实现双主模型高可用集群

    要求:    1. 两台web服务器安装wordpress,数据库通过nfs共享    2. 使用keepalived实现双主模型 环境:    主机:        系统:CentOS6.7 x64 ...

  6. TimeUnit 笔记

    TimeUnit笔记 1.TimeUnit 简介 TimeUnit是java.util.concurrent包下的一个枚举类,其主要封装了时间单位之间的转换以及基于时间上对线程的基本操作(sleep, ...

  7. python 判断平年还是闰年

    while 1: s = input('请填入一个年份:') s = int(s) year = False if s % 100 == 0 and s % 400 == 0: year = True ...

  8. Python shell 控制台,有个快捷键可以向dos那样通过上下键来选择之前输入的内容?

    Alt + p 往前: Alt+n 从头开始历史输入

  9. win32 右键弹出菜单

    #define  CW_ABOUT  100 #define  CW_DOCUMENT 200 POINT t; GetCursorPos(&t); HMENU hMenu,hPopupMen ...

  10. [thinkphp] 公共头部底部如何传递数据

    分组底下有一个公共模板文件夹 Modules/Index/Tpl/public/ 如何传递数据给模板呢? 在  入口文件/Lib/Action/  中创建类CommonAction.class.php ...