Pagination for a list with Spring Pageable

Vinicius Mendes
1 min readJun 15, 2020

I came up with a scenario in my Spring REST API where the source of data wasn’t paginated. In my tests, the ammount of data could be big in some cases so I decided to paginate the data in my API.

As I was already using Spring Pageable in my API an for me it is the natural way to paginate data in Spring APIs. So I created a method to paginate the list of data from my not paginated source:

This way we can keep the same signature for pagination used for Spring Data API. The usage is like this: