Spring boot 弹簧靴2.0.0+;分页、maven和hibernate

Spring boot 弹簧靴2.0.0+;分页、maven和hibernate,spring-boot,pagination,Spring Boot,Pagination,但是,我正在进行springboot分页: repo.findAll(PageRequest.of(第页,大小)) 似乎不起作用 在PageRequest(…)被弃用之后,有人知道SpringBoot2+中分页的新方法吗 提前感谢。您需要一个可分页的对象示例代码段: @Repository public interface MyRepo extends JpaRepository<MyDto, Long> { Page<MyEntity> findAll(Pagea

但是,我正在进行springboot分页:

repo.findAll(PageRequest.of(第页,大小))

似乎不起作用

在PageRequest(…)被弃用之后,有人知道SpringBoot2+中分页的新方法吗


提前感谢。

您需要一个可分页的对象示例代码段

@Repository
public interface MyRepo extends JpaRepository<MyDto, Long> {

  Page<MyEntity> findAll(Pageable page); 

}
这对我有用!确保返回的是
页面而不是列表?

我的错误:repo.findAll(PageRequest.of(Page,size));
... 这是一种工作方法。感谢您的tme@karthik R

请查看此帖子:
@Test
public void testPagination(){
 assertNotNull(myRepo.findAll(PageRequest.of(0, 20)));
}