1.添加pagehelper的jar,我用的是gradle,pom可以自行添加
compile ‘com.github.pagehelper:pagehelper:5.0.0’
注意版本是5.0.0
2.在mybaits配置文件mybatis-config.xml中添加pagehelper组件
添加此组件适用于版本为5.0.0的pagehelper,添加时有顺序要求,plugs添加在后面,我是放在最后面
<plugins>
<plugin interceptor="com.github.pagehelper.PageInterceptor">
<!-- config params as the following -->
<property name="reasonable" value="true" />
</plugin>
</plugins>
3.代码中实现