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

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 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式