I have a simple controller action:
public class CategoriesController
{
@RequestMapping(value = { "/", "" })
public String list(
Model model,
@PageableDefault(size = CategoriesController.PAGE_LIMIT) Pageable pager
)
{
// load page data
Page<Category> page = this.categoryService.findAll(pager);
/* action logic here */
}
}
Here is my pom.xml
fragment:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>1.6.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.5.0.RELEASE</version>
</dependency>
After addtion this to my applicationContext.xml
:
<bean class="org.springframework.data.web.config.SpringDataWebConfiguration"/>
I have following error:
org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.data.domain.Pageable]: Specified class is an interface
Spring Data itself works fine, JPA repositories are working. But until now I had hand-written pagination in controllers (calculating pages on my own, creating PageRequest
objects by hand). I wanted to make use of Spring Data web extras, but they don't work for me for some reason... registering obsolete org.springframework.data.web.PageableArgumentResolver
by hand partially made it working, but not completely, but still, I don't think this should even be a solution.
After enabling debug logger on org.springframework
I see that:
01:37:33.850 [localhost-startStop-1] DEBUG org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method org.springframework.data.web.config.SpringDataWebConfiguration.pageableResolver()
So it's registered - any idea why it's not working?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…