Could not instantiate bean class [org.springframework.data.domain.Pageable]: Specified class is an interface解决方案
原文: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解决方案的更多相关文章
- Could not instantiate bean class [org.springframework.data.mongodb.core.MongoTemplate]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'repositoryDa ...
- springmvc上传文件报错org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.web.multipart.MultipartFile]
在用springmvc+mybatis进行项目开发时,上传文件抛异常... org.springframework.beans.BeanInstantiationException: Could no ...
- Could not instantiate bean class [org.springframework.web.multipart.MultipartFile]: Specified class
如果在使用SpringMVC中使用文件上传的MultipartFile对象时,出现了以下的错误: Could not instantiate bean class [org.springframewo ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- 图论:Dinic算法
解决最大流问题我搜到了一堆的算法:EK算法.FF算法.Dinic算法.SAP算法.ISAP算法 然而并没有什么鸟用 掌握最常见的Dinic就够了,据说极限优化的ISAP比Dinic更快一些..我当不知 ...
- 金中欢乐赛 C题
题目传送门 这道题 hash就可以写了 弄了半天有点智障 强行压一压就okay了的说 #include<cstdio> #include<cstring> #include&l ...
- cobalt strike使用笔记
启动: ./teamserver 192.168.74.1 admin #启动cs服务器.admin为密码. 监听器: windows/beacon_dns/reverse_dns_txtwindow ...
- SUSE LINUX 11忘记密码的解决方法
忘记ROOT的密码 1.重新启动机器,在出现grub引导界面后,在启动linux的选项里加上init=/bin/bash,通过给内核传递init=/bin/bash参数使得OS在运行login程序之前 ...
- ARM-Linux (临时,正式) 建立页表的比较【转】
转自:http://blog.csdn.net/edwardlulinux/article/details/38967521 版权声明:本文为博主原创文章,未经博主允许不得转载. 很久没有写博客了 ...
- GLE api
# -*- coding: utf-8 -*-# @Time : 2018/03/09 12:25# @Author : cxa# @File : gle.py# @Software: PyCharm ...
- centos7安装tengine强制使用HTTPS访问
操作系统:centos7.2 x64tengine:Tengine/2.2.0主机IP: 10.0.0.12 一.安装tengine 1.1 下载源码安装包 1.1.1 源码包pcre-8.40 ...
- Django基础之模板
Django模板系统 官方文档 常用语法 只需要记两种特殊符号: {{ }} 和 {% %} 变量相关的用{{ }},逻辑相关的用{% %}. 变量 {{ 变量名 }} 变量名由字母数字和下划线组成 ...
- 【LeedCode】3Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all un ...
- debian 更换sh的默认链接为bash
https://blog.csdn.net/mudongliangabcd/article/details/43458895