原文: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. HoneyPy 模拟Nginx服务器脚本

    HoneyPy是一个Python写的低交互式蜜罐,可以通过自定义Plugins的方式来配置不同的场景.这里是一个模拟Nginx空白页面的代码: # Auth xiaoxiaoleo # http:// ...

  2. Python学习笔记 - day4 - 流程控制

    Python流程控制 Python中的流程控制主要包含两部分:条件判断和循环. Python的缩进和语法 为什么要在这里说缩进和语法,是因为将要学习的条件判断和分支将会涉及到多行代码,在java.c等 ...

  3. 大话Linux内核中锁机制之原子操作、自旋锁【转】

    转自:http://blog.sina.com.cn/s/blog_6d7fa49b01014q7p.html 多人会问这样的问题,Linux内核中提供了各式各样的同步锁机制到底有何作用?追根到底其实 ...

  4. Linux设置编译器环境变量

    Linux设置编译器环境变量 https://jingyan.baidu.com/article/9f7e7ec0bb22aa6f29155453.html Linux添加环境变量与GCC编译器添加I ...

  5. selenium与360极速浏览器driver配置

    1)下载浏览器对应的driver,浏览器版本与driver对应关系,网址:http://www.cnblogs.com/JHblogs/p/7699951.html:driver下载地址:http:/ ...

  6. BZOJ 3098

    : Hash Killer II 时间限制: Sec 内存限制: MBSec Special Judge 提交: 解决: [提交][][] 题目描述 这天天气不错,hzhwcmhf神犇给VFleaKi ...

  7. jQuery中操作样式

    操作行间样式 // 获取div的样式 $("div").css("width"); $("div").css("color&quo ...

  8. Selenium2+python自动化53-unittest批量执行(discover)【转载】

    前言 我们在写用例的时候,单个脚本的用例好执行,那么多个脚本的时候,如何批量执行呢?这时候就需要用到unittet里面的discover方法来加载用例了. 加载用例后,用unittest里面的Text ...

  9. AC日记——[ZJOI2007]报表统计 bzoj 1058

    1058 思路: 平衡树的题: 然而我的平衡树写一次炸一次QwQ: 而且各种tle: 所以stl水过: 代码: #include <set> #include <cstdio> ...

  10. python读取大文件【一行一行读取】

    with open('e:/content.txt') as f: for line in f: if '==3346628==' in line: …………