首先需要一个pageHelper.
pom.xml
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.10</version>
</dependency>
yml 配置
#pagehelper
pagehelper:
helperDialect: mysql
reasonable: true
supportMethodsArguments: true
params: count=countSql
dao 层写一个分页方法
Page<Event> findByPage(int pId);
mapper
<select id="findByPage" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from event
where pId = #{pId,jdbcType=INTEGER} </select>
PageInfo 类
import com.github.pagehelper.Page;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
public class PageInfo<T> implements Serializable {
private static fina