1、导入依赖
<!-- MyBatis 分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
</dependency>
2、在SqlSessionFactoryBean进行配置
<!-- 配置插件 -->
<property name="plugins">
<array>
<!-- 配置PageHelper插件, bean的id可以不用写,内部bean -->
<bean class="com.github.pagehelper.PageHelper">
<property name="properties">
<props>
<!-- 数据库方言 -->
<prop key="dialect">mysql</prop>
<!-- 页码的合理化修正 在1~总页数之间修正页码 -->
<prop key="reasonable">true</prop>
</props>
</property>
</bean>
</array>
</property>