分页查询 pagehelper

导入依赖

        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <!-- 特别注意版本问题 -->
            <version>1.2.3</version>
        </dependency>

application.yml

pagehelper:
  helper-dialect: mysql
  reasonable: true
  support-methods-arguments: true

bookController.java

public class bookController {
    @Autowired
    bookService bookservice;
	@GetMapping("/findAll")
	public PageInfo<Books> findAll(){
        PageHelper.startPage(3, 1);  //这个下边紧接着查询语句
        List<Books> books = bookservice.selectAll();
        PageInfo<Books> pageInfo = new PageInfo<>(books);
        return  pageInfo;
	}
}
上一篇:Mybatis(pagehelper)


下一篇:PageHelper 记录总条数不正确问题处理