yy823767532 2017-06-28 06:08 采纳率: 0%
浏览 5782

springboot mybatis 使用分页插件pagehelper 分页不生效

最近在学习springboot集成mybatis的知识,在使用分页时候,遇到如下问题
添加的分页插件,但是分页效果没有
代码如下
maven引入如下

        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.2.0</version>
        </dependency>
            <!-- 分页插件 -->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper</artifactId>
            <version>4.1.0</version>
        </dependency>

mybatis-config配置如下

 <properties>
        <property name="dialect" value="mysql" />
    </properties>

     <settings>  
        <!-- 打印查询语句 -->  
        <setting name="logImpl" value="SLF4J" />  
    </settings>  

    <!-- 分页插件的配置 -->
  <plugins>
        <plugin interceptor="com.github.pagehelper.PageHelper">

        </plugin>
    </plugins>

分页代码如下

  @RequestMapping("/pagelist")
      @ResponseBody
      public Object showQuestions(@RequestParam Integer page, @RequestParam Integer pageSize) {
                Page<Object> b = PageHelper.offsetPage(2,10);
                System.out.println(b);
                List <UserEntity> lists= userMapper.getAll();
                PageInfo<UserEntity> pageinfo = new PageInfo<UserEntity>(lists);
                return pageinfo;

      }

但是查询的数据,仍然是全部数据,没有按照预想的实现分页

  • 写回答

4条回答 默认 最新

  • GreenRookie 2017-06-28 06:14
    关注

    http://download.csdn.net/detail/fiangasdre/9656955看看我里面做的说明。
    在spring中加载






    <!-- 自动扫描entity目录必须配置,否则报错找不到类 -->



    评论

报告相同问题?

悬赏问题

  • ¥100 求数学坐标画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站