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 ...
随机推荐
- 【20160815】noip模拟(未完)
#include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #inc ...
- keras_训练人脸识别模型心得
keras_cnn_实现人脸训练分类 废话不多扯,直接进入正题吧!今天在训练自己分割出来的图片,感觉效果挺不错的,所以在这分享一下心得,望入门的同孩采纳. 1.首先使用python OpenCV库里面 ...
- webdriver函数
import sys; print('%s %s' % (sys.executable or sys.platform, sys.version)) PyDev console: starting. ...
- maven中的pom.xml解析
pom.xml用于项目描述,组织管理,依赖管理和构件信息的管理. <project>是pom.xml的一些约束信息: <modelVersion>指定了当前pom的版本: 坐标 ...
- 2.aiomysql实现对数据库异步读取
有一个库叫做aiomysql,这是一个基于asyncio和pymysql的库.至于为什么可以在tornado中使用,是因为高版本tornado的底层使用了asyncio. import asyncio ...
- React.js入门
React 入门实例教程 现在最热门的前端框架,毫无疑问是 React . 上周,基于 React 的 React Native 发布,结果一天之内,就获得了 5000 颗星,受瞩目程度可见一斑. ...
- Tkinter 计算器
from tkinter import * master = Tk() frame = Frame(master) frame.pack(padx=10,pady=10) v1 = StringVar ...
- hdu 1507(二分图匹配)
Uncle Tom's Inherited Land* Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- POJ 1163.The Triangle-动态规划
The Triangle Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 50122 Accepted: 30285 De ...
- Android Studio查找功能(搜索功能)
F3 向下查找关键字出现位置 Shift+F3 向上一个关键字出现位置 2.在当前工程内查找文本[Ctrl+Shift+F] 先会弹出一个对话框,直接点击[find],开始在整个工程内查找该字符串 ...