Spring: Pageable data on controller

Viewed 24

Inside spring libraries there are two Pageable classes:

  • org.springframework.boot.autoconfigure.data.web.SpringDataWebProperties.Pageable
  • org.springframework.data.domain.Pageable

Which one should I use into my controllers and into my repositories?

1 Answers

spring-data-commons' domain.Pageable class is for the Page's info: like offset, size, sort; which is the input to the Repositories;

spring-boot-autoConfigure's SpringDataWebProperties.Pageable is a static inner class with some defaults for the above, which you can override, for example

spring.data.web.pageable.default-page-size=50 # default is 20 spring.data.web.pageable.max-page-size=200 # 2000

Related