在mybatis中,先导入pagehelper.jar所需的jar包,然后在sqlMapConfig,xml中配置插件
<plugins>
<!-- com.github.pagehelper为PageHelper类所在包名 -->
<plugin interceptor="com.github.pagehelper.PageHelper">
<!-- 设置数据库类型 Oracle,Mysql,MariaDB,SQLite,Hsqldb,PostgreSQL六种数据库-->
<property name="dialect" value="mysql"/>
</plugin>
</plugins>
配置好插件后就进行测试
public class TestPagehelper {
@Test
public void test(){
//读取applicationContext配置文件
ApplicationContext context=new ClassPathXmlApplicationContext("classpath:spring/applicationContext-dao.xml");
//获取mapper代理对象
TbItemMapper mapper = context.getBean(TbItemMapper.class);
//执行查询语句
TbItemExample example = ne