SpringBoot如何整合Mybatis使用pagehelper
前言
小白成长日记之pagehelper的使用
一、什么是pagehelper?
PageHelper是一款好用的开源免费的Mybatis第三方物理分页插件
二、步骤
1.在pom.xml中引入Pagehelper相关依赖
代码如下(示例):
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.3.0</version>
</dependency>
2.在application.yml或者是application.propoties中配置
代码如下:
pagehelper:
helper-dialect: mysql
reasonable: true
support-methods-arguments: true
params: count=countSql
mybatis:
mapper-locations: com/hdb/mapper/*.xml
helper-dialect:指定数据库,不指定的话会默认自动检测数据库类型
mapper-locations: 配置mapper的路径。
pagehelpe中的内容具体可查看
链接: https://github.com/abel533/MyBatis-Spring-Boot.
3.对应的Mapper和Mapper.xml
4.对应的Service
5对应的Controller
总结
pageinfo里面包含了很多属性,可以择优选择