pageHelper踩坑记录

pageHelper:好处就是使用简单,自动帮忙进行物理分割查询

  1. 断点截图

表中有4条数据,mapper是查询所有数据的。根据断点截图,可以看出pageHelper的确是进行了物理分割查询

    //查询所有产品信息
    @Select({"select * from", TABLE_NAME})
    List<Product> SelectProducts();
image.png
  1. 网上教程的坑

SpringBoot只需要这个依赖就行了,其它都自带或内包括了。网上很多教程会把pagehelper、pagehelper-spring-boot-autoconfigure都放进依赖,虽然不会报错,但是不优雅!!!

      <!-- SpringBoot不需要以下二个插件依赖 -->
      <dependency>
        <groupId>com.github.pagehelper</groupId>
        <artifactId>pagehelper</artifactId>
        <version>5.0.0</version>
      </dependency>
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-autoconfigure</artifactId>
            <version>1.2.3</version>
        </dependency>


        <!-- 只需要下面这个插件依赖就行了 -->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.2.3</version>
        </dependency>
  1. YML配置也简单

#配置分页插件pagehelper
pagehelper:
    helperDialect: mysql
    reasonable: true
    supportMethodsArguments: true
    params: count=countSql
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,408评论 19 139
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,491评论 25 709
  • 集成mybatis [toc]简书不支持目录,截图。 mybatis 注解方式 第一步:引入依赖包: build....
    inke阅读 12,298评论 1 6
  • 读过狼图腾的朋友都知道,蒙古人之所以能在此种恶劣的生活条件下克服自然,全靠他们身上那种与生俱来的狼性血液。蒙古人征...
    佳英sir阅读 3,101评论 0 1
  • 2017.10.23 【1】意想不到的事情:分享就是是一种快乐,无论是任何分享。(先说今天吃了他们好吃的东西,一个...
    吻蝶恋阅读 1,833评论 0 0