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目录必须配置,否则报错找不到类 -->



    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题