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

很遺憾,使用這兩種方法后直接報錯:

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

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM