SpringBoot Mybatis PageHelper分页插件的两种用法(二)
2017-11-22 22:06
1031 查看
与第一种方式的区别 1、替换pom.xml中的依赖
<!--mybatis分页插件--> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>1.0.0</version> </dependency>2、注释 mybatis-config中的plugins插件,测试很多遍打开就执行不正确,注释就可以了,估计是自身就已经开启了拦截器
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPEconfigurationPUBLIC"-//mybatis.org//DTD Config 3.0//EN""http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <settings> <setting name="logImpl" value="STDOUT_LOGGING"/> </settings> <!-- Entity别名 在application.yml里已配置 <typeAliases> <typeAlias type="com.ybf.activity.web.entity.Student" alias="Student" /> </typeAliases> --> <!-- <plugins>--> <!--mybatis分页插件--> <!-- <plugin interceptor="com.github.pagehelper.PageInterceptor">--> <!--指明数据库 4.0.0以后不需要设置此属性--> <!--<property name="dialect" value="mysql"/>--> <!-- 该参数默认为false --> <!-- 设置为true时,会将RowBounds第一个参数offset当成pageNum页码使用 --> <!-- 和startPage中的pageNum效果一样--> <!--<property name="offsetAsPageNum" value="false"/>--> <!-- 该参数默认为false --> <!-- 设置为true时,使用RowBounds分页会进行count查询 --> <!--<property name="rowBoundsWithCount" value="false"/>--> <!-- 设置为true时,如果pageSize=0或者RowBounds.limit = 0就会查询出全部的结果 --> <!-- (相当于没有执行分页查询,但是返回结果仍然是Page类型)--> <!-- <property name="pageSizeZero" value="false"/>--> <!-- 3.3.0版本可用 - 分页参数合理化,默认false禁用 --> <!-- 启用合理化时,如果pageNum<1会查询第一页,如果pageNum>pages会查询最后一页 --> <!-- 禁用合理化时,如果pageNum<1或pageNum>pages会返回空数据 --> <!--<property name="reasonable" value="false"/>--> <!-- 支持通过Mapper接口参数来传递分页参数 --> <!--<property name="supportMethodsArguments" value="false"/>--> <!-- always总是返回PageInfo类型,check检查返回类型是否为PageInfo,none返回Page --> <!--<property name="returnPageInfo" value="none"/>--> <!-- </plugin>--> <!-- </plugins>--> <!-- Mapper 在application.yml里已配置 <mappers> <mapper resource="mybatis/mapper/mysql/StudentMapper.xml"/> </mappers> --> </configuration>
3、测试就可以了
==> Preparing: SELECT count(0) FROM mobile_nav ==> Parameters: <== Columns: count(0)<== Row: 4<== Total: 1==> Preparing: select * from mobile_nav LIMIT 2 ==> Parameters: <== Columns: nav_id, nav_name, link_url, icon, sort<== Row: N000001, 首页, /index, icon-home, 1<== Row: N000002, 预约, /doctor, icon-bubbles4, 2<== Total: 2Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7b6854b5]2017-11-22 21:55:14.041 [main] INFO com.lming.chcservice.mapper.MobileNavMapperTest - N0000012017-11-22 21:55:14.041 [main] INFO com.lming.chcservice.mapper.MobileNavMapperTest - 首页2017-11-22 21:55:14.041 [main] INFO com.lming.chcservice.mapper.MobileNavMapperTest - N0000022017-11-22 21:55:14.041 [main] INFO com.lming.chcservice.mapper.MobileNavMapperTest - 预约
相关文章推荐
- SpringBoot Mybatis PageHelper分页插件的两种用法(一)
- spring-boot 集成mybatis的分页插件PageHelper和Generator (番外)
- 记录问题:springboot中使用Mybatis-pagehelper分页插件遇到的版本兼容问题
- spring-boot 集成mybatis的分页插件PageHelper和Generator (番外)
- [置顶] MyBatis基于Spring-boot集成通用Mapper以及pagehelper分页插件(含源码下载)
- SpringBoot集成MyBatis的分页插件PageHelper(回头草)
- Mybatis分页插件 - PageHelper与springBoot的整合
- SpringBoot集成MyBatis的分页插件PageHelper(回头草)
- springboot如何集成mybatis的pagehelper分页插件
- spring-boot 集成mybatis的分页插件PageHelper和Generator
- Spring Boot系列六 Spring boot集成mybatis、分页插件pagehelper
- Spring Boot系列教程十一: Mybatis使用分页插件PageHelper
- SpringBoot分页插件PageHelper
- springboot + mybatis-pagehelper 参数查询不分页的bug。。。
- springboot中分页插件pageHelper的使用
- SpringBoot集成分页插件PageHelper
- SpringBoot中使用MyBatis,使用PageHelper进行分页查询以及碰到的错误
- SpringBoot集成Mybatis并具有分页功能PageHelper
- spring+mybatis利用pageHelper分页插件分页
- Mybatis分页插件PageHelper正确的用法(网上有2篇不够科学的文章)