0 Introduction
With mybatis, then paging is essential, basically with PageHelper this tab plug-in, easy to use convenient;
1, to achieve
1.1, adding a dependency:
<!-- 3、集成 mybatis pagehelper--> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>1.2.10</version> </dependency>
1.2, increase the profile configuration items:
pagehelper.helper-dialect=mysql
1.3, use:
int startPage= 2; int pageSize= 2; PageHelper.startPage(startPage, pageSize); PageHelper.orderBy("id ASC"); List<User> allUser = userservice.getAll(); return allUser ;
Complete, it is not very simple!