分页插件

添加pom依赖

<!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter -->
<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper-spring-boot-starter</artifactId>
    <version>2.1.0</version>
</dependency>

在application.yml中添加如下配置

pagehelper:
  reasonable: true
  support-methods-arguments: true
  params: count=countSql
  helper-dialect: mysql
@GetMapping("/api/user17")
public Object user17() {
    PageHelper.startPage(1, 10);
    val user = new User();
    user.setName("丽丽");
    user.setAge(18);
    return userMapper.selectUser(user);
}

最后更新于

这有帮助吗?