MyBatis分页插件

---------------------siwuxie095

  

  

  

  

  

  

  

  

  

MyBatis 分页插件

  

  

1、MyBatis 的分页插件 PageHelper分页助手) 实现了通用的分页

查询,并支持任何复杂的单表、多表分页。目前,该插件支持MySQL、

Oracle、SQL Server、DB2、PostgreSQL 等主流数据库的物理分页

  

  

  

2、分页插件 PageHelper 的 Github 链接:

  

https://github.com/pagehelper/Mybatis-PageHelper

  

  

  

3分页插件需要搭配sql 解析工具使用,所以引入分页插件有两种方式

  

1引入jar 包

  

1)PageHelper 的下载链接如下:

  

https://oss.sonatype.org/content/repositories/releases/com/github/pagehelper/pagehelper/

  

  

http://repo1.maven.org/maven2/com/github/pagehelper/pagehelper/

  

  

2)JSqlParser 的下载链接如下:

  

http://repo1.maven.org/maven2/com/github/jsqlparser/jsqlparser/0.9.5/

  

  

2使用Maven

  

Maven 项目的核心配置文件pom.xml 中添加如下依赖:

  

<dependency>

<groupId>com.github.pagehelper</groupId>

<artifactId>pagehelper</artifactId>

<version>最新版本</version>

</dependency>

  

<dependency>

<groupId>com.github.jsqlparser</groupId>

<artifactId>jsqlparser</artifactId>

<version>最新版本</version>

</dependency>

  

  

  

4、在MyBatis 核心配置文件 mybatis-config.xml 中进行配置

  

1)如果PageHelper 的 jar 包版本是 4.x,则为:

  

<plugins>

 

<!-- com.github.pagehelperPageHelper类所在包名 -->

<plugininterceptor="com.github.pagehelper.PageHelper">

 

<!-- 指定数据库的方言为mysql -->

<propertyname="dialect"value="mysql"/>

<!-- 该参数默认为false -->

<!-- 设置为true时,使用RowBounds分页会进行count查询 -->

<propertyname="rowBoundsWithCount"value="true"/>

 

</plugin>

 

</plugins>

  

  

  

2)如果PageHelper 的 jar 包版本是 5.x,则为:

  

<plugins>

 

<!-- com.github.pagehelperPageInterceptor类所在包名 -->

<plugininterceptor="com.github.pagehelper.PageInterceptor">

 

<!-- 指定数据库的方言为mysql -->

<propertyname="helperDialect"value="mysql"/>

<!-- 该参数默认为false -->

<!-- 设置为true时,使用RowBounds分页会进行count查询 -->

<propertyname="rowBoundsWithCount"value="true"/>

 

</plugin>

 

</plugins>

  

  

  

注:截止目前(2018/01/29),PageHelper 的最新版本是 5.1.2

  

  

  

5、其它配置及使用方法,详见如下链接:

  

https://github.com/pagehelper/Mybatis-PageHelper/blob/master/wikis/zh/HowToUse.md

  

  

  

  

  

  

  

  

  

  

【made by siwuxie095】

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值