原文: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. [BZOJ1005]Prufer数列+排列组合

    一棵树的Prufer数列 每次在剩下的树中找到标号最小的叶子节点(对于无根树而言即是度数为1的节点),删去. 同时将其父节点(即与其相连的唯一点)加入Prufer数列当中. 一个Prufer数列所对应 ...

  2. 【Atcoder】ARC 080 F - Prime Flip

    [算法]数论,二分图最大匹配 [题意]有无限张牌,给定n张面朝上的牌的坐标(N<=100),其它牌面朝下,每次操作可以选定一个>=3的素数p,并翻转连续p张牌,求最少操作次数使所有牌向下. ...

  3. swift mac 使用git, 并使用osc, 打开当前目录命令在终端输入 open . windows 下为start .

    使用git.osc而不用github, 因为在osc里面可以设置私有项目,而不需要公开. ssh-keygen -t rsa -C "email@email.com" mac下生成 ...

  4. Django【进阶】序列化

    关于Django中的序列化主要应用在将数据库中检索的数据返回给客户端用户,特别的Ajax请求一般返回的为Json格式. 方案一:serializers 1 2 3 4 5 fromdjango.cor ...

  5. pyhton发送邮件

    # import smtplib # from email.mime.text import MIMEText # _user = "你的qq邮箱" # _pwd = " ...

  6. git 提示 Please move or remove them before you can merge 解决办法

    解决Git冲突造成的Please move or remove them before you can merge git clean -d -fx其中x -----删除忽略文件已经对git来说不识别 ...

  7. 原型 Boolean String Math Date知识点

    原型 1.定义 每一个对象都有原型 原型仍然是一个对象 模拟实现面向对象的继承性 2.原型链 对象的原型还有原型 对象除了可以使用自有属性还可以继承原型上的属性 3.获取原型 对象.__proto__ ...

  8. css左右箭头

    .record-left{ content: ""; width: 0; height: 0; float: left; border-top: 10px solid transp ...

  9. 【SQL】多个表的查询

    1.元组变量 SELECT * FROM a AS x, a AS y; 结果是显示自己和自己的笛卡尔乘积. 如果查询中对于某一个关系使用了多次,为了区别他们的属性,需要对关系定义别名,然后用 别名. ...

  10. Selenium2+python自动化36-判断元素存在【转载】

    前言 最近有很多小伙伴在问如何判断一个元素是否存在,这个方法在selenium里面是没有的,需要自己写咯. 元素不存在的话,操作元素会报错,或者元素有多个,不唯一的时候也会报错.本篇介绍两种判断元素存 ...