PageRequest constructors have been deprecated

前端 未结 3 1503
粉色の甜心
粉色の甜心 2020-12-08 09:30

I\'m working the Spring Data Commons v2+ snapshot, and I see that the constructors for a PageRequest have been deprecated. This appears to have occurred betwee

相关标签:
3条回答
  • 2020-12-08 10:05

    We can use PageRequest.of(offset, limit) instead of new PageRequest(offset, limit). In this case we don't need to use deprecated constructor.

    0 讨论(0)
  • 2020-12-08 10:11

    It's just the constructors which have been deprecated. Instead of

    new PageRequest(firstResult, maxResults, new Sort(...))
    

    you can now use

    PageRequest.of(firstResult, maxResults, Sort.by(...))
    

    and that's it.

    0 讨论(0)
  • 2020-12-08 10:12

    You can use the following solution to solve your problem:

    Page<User> users=userService.findByUserType(id,PageRequest.of(1, 3));
    
    0 讨论(0)
提交回复
热议问题