引入包
https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter/1.2.10

<!--分页--><!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter --><dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper-spring-boot-starter</artifactId><version>1.2.10</version></dependency>

配置文件


import com.github.pagehelper.PageHelper;
import org.apache.ibatis.session.Configuration;
import org.mybatis.spring.boot.autoconfigure.ConfigurationCustomizer;
import org.springframework.context.annotation.Bean;
import java.util.Properties;/***配置文件* @author liwen406* @date 2019-04-20 12:14 2019-04-20 13:20*/
@org.springframework.context.annotation.Configuration
public class MyBatisConfig {/*** 目的防止驼峰命名规则* @return*/@Beanpublic ConfigurationCustomizer configurationCustomizer(){return new ConfigurationCustomizer(){@Overridepublic void customize(Configuration configuration) {configuration.setMapUnderscoreToCamelCase(true);}};}/*** 分页插件* @return*/@Beanpublic PageHelper pageHelper() {System.out.println("MyBatisConfiguration.pageHelper()");PageHelper pageHelper = new PageHelper();Properties p = new Properties();p.setProperty("offsetAsPageNum", "true");p.setProperty("rowBoundsWithCount", "true");p.setProperty("reasonable", "true");pageHelper.setProperties(p);return pageHelper;}
}

dao mapper

@Select("SELECT * from tbl_emp")List<Employee> selectByExample(Employee example);

Service

   @Overridepublic List<Employee> selectByExample() {return projectInfodao.selectByExample(null);}

Controller

    @GetMapping("/page/{start}/{end}")@ResponseBodypublic List<Employee> likeName(@PathVariable int start, @PathVariable int end) throws Exception {/** 第一个参数:第几页;* 第二个参数:每页获取的条数.*/PageHelper.startPage(start, end);return projectInfService.selectByExample();}

转载于:https://blog.51cto.com/357712148/2381845

Spring Boot 整合Pagehelper(为什么PageHelper分页不生效)相关推荐

  1. spring boot整合mybatis+通用mapper+pagehelper分页插件

    spring boot整合mybatis+通用mapper+pagehelper分页插件 pom依赖 <?xml version="1.0" encoding="U ...

  2. Spring Boot 整合MyBatis(23)

    Spring Boot 整合MyBatis Spring Boot 整合 Druid 引入依赖 配置 application.yml pring Boot 整合 tk.mybatis 引入依赖 配置 ...

  3. VUE+Spring Boot整合MyBatis实现前后端分离项目壁纸网站

    目录 前言 一.项目运行 二.环境需要 三.技术栈 四.项目说明 五.后端代码 前言 每次换桌面,壁纸总是不好找,搜索图片得不到好的索引与反馈,很难找到自己喜欢的壁纸,而壁纸网站可以免去我们去寻找壁纸 ...

  4. 五、spring boot整合mybatis-plus

    spring boot整合mybatis-plus 简介 mybatis 增强工具包,简化 CRUD 操作. 文档 http://mp.baomidou.com http://mybatis.plus ...

  5. springboot整合hibernate_峰哥说技术系列-17 .Spring Boot 整合 Spring Data JPA

    今日份主题 Spring Boot 整合 Spring Data JPA JPA(Java Persistence API)是用于对象持久化的 API,是Java EE 5.0 平台标准的 ORM 规 ...

  6. Elasticsearch学习(3) spring boot整合Elasticsearch的原生方式

    前面我们已经介绍了spring boot整合Elasticsearch的jpa方式,这种方式虽然简便,但是依旧无法解决我们较为复杂的业务,所以原生的实现方式学习能够解决这些问题,而原生的学习方式也是E ...

  7. Elasticsearch实战篇——Spring Boot整合ElasticSearch

    2019独角兽企业重金招聘Python工程师标准>>> 当前Spring Boot很是流行,包括我自己,也是在用Spring Boot集成其他框架进行项目开发,所以这一节,我们一起来 ...

  8. Spring boot 整合Spring Security Jwt

    记录学习Spring boot 整合Spring Security Jwt 学习参考 – 慢慢的干货 https://shimo.im/docs/OnZDwoxFFL8bnP1c/read 首先创建S ...

  9. ElasticSearch教程与实战:从搭建服务到Spring Boot整合

    目录 写在前面 Elasticsearch是什么?可以解决什么问题? 关于Elasticsearch版本的选择 Elasticsearch的几个基本概念 索引(index) 类型(type) 文档(d ...

  10. 【SpringBoot学习】28、Spring Boot 整合 TKMybatis 通用 Mapper

    文章目录 Spring Boot 整合 TKMybatis 自定义父类接口 新增接口 新增之后回显 Id 更新 删除 单查询 查询列表 计数 条件构造器 技术分享区 Spring Boot 整合 TK ...

最新文章

  1. 哪些电脑最适合做机器学习、数据科学和深度学习呢?这里有份调研报告
  2. Linux 6.8 root密码丢失找回
  3. Java技术:收集16 条 yyds 的代码规范,值得一读!
  4. Linux安装MariaDB(Mysql)和简单配置
  5. “恭喜那些拿到 Java 月薪 2 万 Offer 的人”
  6. InfoGAN详细介绍及特征解耦图像生成
  7. matlab矩阵倒数,求解:用MATLAB生成空间距离倒数矩阵后面板分析出现下面的几句警告...
  8. 开源GIS平台实战项目的总结
  9. Win10系统微信,QQ打语音听不见声音
  10. 物联网毕业设计 - 物联网毕设项目分享 有趣的毕设项目(单片机 嵌入式 物联网 stm32)
  11. 公式编辑器中如何修改字体?
  12. win7 计算机和控制面板突然打不开,显示服务器运行失败
  13. JS 数字,金额 用逗号 隔开(数字格式化)
  14. 积木式移动互联网App Hybrid框架-modular
  15. Cocos技术派 | TS版属性面板定义高级用法
  16. SpringBoot-配置actuator
  17. Android中APK打包流程
  18. 在VS2010中ActiveX控件注册方法,使用regsvr32命令
  19. element 合计
  20. 小i机器人软件工程师揭秘机器人的“脑细胞”NLU

热门文章

  1. tplink wr886n v5.0 ttl 接线方法
  2. 同花顺的数据格式总览(转帖)
  3. ORB-SLAM2 论文翻译
  4. 【Math】P=NP问题
  5. 【C++】【六】约瑟夫问题
  6. c语言inline详解
  7. Redis客户端JetCache的单机版和集群版的配置
  8. jQuery日期选择器插件date-input
  9. WISMO模块GPRS上网设置的过程
  10. 深度分析define预处理指令