添加MyBatis的代码,地址

  1. https://www.cnblogs.com/tianhengblogs/p/9537665.html

修改以下部分:

1.添加MyBatisConfig

  1. package myshop.config;
  2.  
  3. import java.util.Properties;
  4.  
  5. import org.springframework.context.annotation.Bean;
  6. import org.springframework.context.annotation.Configuration;
  7.  
  8. import com.github.pagehelper.PageHelper;
  9.  
  10. @Configuration
  11. public class MyBatisConfig {
  12. @Bean
  13. public PageHelper pageHelper()
  14. {
  15. System.out.println("Use PageHelper");
  16. PageHelper pageHelper = new PageHelper();
  17. Properties p = new Properties();
  18. p.setProperty("offsetAsPageNum", "true");
  19. p.setProperty("rowBoundsWithCount", "true");
  20. p.setProperty("reasonable", "true");
  21. pageHelper.setProperties(p);
  22. return pageHelper;
  23. }
  24. }

2.修改MyBatisController

  1. package myshop.controller;
  2.  
  3. import java.util.List;
  4.  
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.web.bind.annotation.RequestMapping;
  7. import org.springframework.web.bind.annotation.RestController;
  8.  
  9. import com.github.pagehelper.PageHelper;
  10.  
  11. import myshop.bean.UserInfo;
  12. import myshop.service.MyBatisService;
  13.  
  14. @RestController
  15. public class MyBatisController {
  16. @Autowired
  17. private MyBatisService myBatisService;
  18.  
  19. @RequestMapping("likeName")
  20. public List<UserInfo> likeName(String username)
  21. {
  22. PageHelper.startPage(1,2);
  23. return myBatisService.likeName(username);
  24. }
  25. }

3.访问地址

  1. http://localhost:8080/likeName?username=天恒

SpringBoot------集成PageHelper分页功能的更多相关文章

  1. SpringBoot集成PageHelper时出现“在系统中发现了多个分页插件,请检查系统配置!”

    近日在项目中使用SpringBoot集成PageHelper后,跑单元测试时出现了"在系统中发现了多个分页插件,请检查系统配置!"这个问题. 如下图所示: org.mybatis. ...

  2. Springboot 系列(十二)使用 Mybatis 集成 pagehelper 分页插件和 mapper 插件

    前言 在 Springboot 系列文章第十一篇里(使用 Mybatis(自动生成插件) 访问数据库),实验了 Springboot 结合 Mybatis 以及 Mybatis-generator 生 ...

  3. springboot集成PageHelper,支持springboot2.0以上版本

    第一步:pom文件还是需要引入依赖 <!--mybatis的分页插件--> <dependency> <groupId>com.github.pagehelper& ...

  4. springboot集成pagehelper插件

    1.在pom.xml中引入依赖 <dependency> <groupId>com.github.pagehelper</groupId> <artifact ...

  5. SpringBoot集成Mybatis-PageHelper分页工具类,实现3步完成分页

    在Mybatis中,如果想实现分页是比较麻烦的,首先需要先查询出总的条数,然后再修改mapper.xml,为sql添加limit指令. 幸运的是现在已经不需要这么麻烦了,刘大牛实现了一个超牛的分页工具 ...

  6. springboot + mybatis +pageHelper分页排序

    今天下午写查出来的数据的排序,原来的数据没有排序,现在把排序功能加上...原来用的,是xml中的sql动态传参 ,,1个小数没有弄出来,果断放弃... 网上百度一下,发现用pageHelper  可以 ...

  7. springboot mybatis pagehelper 分页问题

    1:添加依赖 compile group: 'com.github.pagehelper', name: 'pagehelper-spring-boot-starter', version: '1.2 ...

  8. Springboot 使用PageHelper分页插件实现分页

    一.pom文件中引入依赖 二.application.properties中配置以下内容(二选一方案) 第一种:pagehelper.helper-dialect=mysqlpagehelper.re ...

  9. SpringBoot+Mybatis+Pagehelper分页

    1.pom.xml <!-- mybatis分页插件 --> <dependency> <groupId>com.github.pagehelper</gro ...

  10. springboot系列十五、springboot集成PageHelper

    一.介绍 项目中经常会遇到分页,PageHelper为我们解决了这个问题.本质上实现了Mybatis的拦截器,作了分页处理. 二.配置PageHelper 1.引入依赖 pagehelper-spri ...

随机推荐

  1. Mysql5.7主主互备安装配置

    一.安装说明 ======================================================================================= 环境:   ...

  2. 首部讲Python爬虫电子书 Web Scraping with Python

    首部python爬虫的电子书2015.6pdf<web scraping with python> http://pan.baidu.com/s/1jGL625g 可直接下载 waterm ...

  3. java操作大文件复制

    https://www.cnblogs.com/coprince/p/6594348.html https://blog.csdn.net/w592376568/article/details/796 ...

  4. WebUpload formdata 上传参数

    https://www.cnblogs.com/wisdo/p/6159761.html webUploader 是款很好用的优秀的开源上传组件,由百度公司开发,详细的介绍可参见webUploader ...

  5. android 判断左右滑动,上下滑动的GestureDetector简单手势检测

    直接加入监听GestureDetector放在需要判断滑动手势的地方: import android.app.Activity; import android.os.Bundle; import an ...

  6. SparkR初体验2.0

    突然有个想法,R只能处理百万级别的数据,如果R能运行在Spark上多好!搜了下发现13年SparkR这个项目就启动了,感谢美帝! 1.你肯定得先装个spark吧.看这:Spark本地模式与Spark ...

  7. GridView Print and Print Preview

    sing System.Linq; using System.Printing; using System.Windows; using System.Windows.Controls; using ...

  8. (笔记)Mysql命令use:使用数据库

    use命令可以让我们来使用数据库. use命令格式: use <数据库名>; 例如,如果xhkdb数据库存在,尝试存取它:   mysql> use xhkdb;屏幕提示:Datab ...

  9. python2 python3 字符串 编码格式 处理

    使用python的ctypes调用c语言中的函数,传入字符串,打印输出异常.解决方法记录于此. 参考连接: http://blog.csdn.net/u011546806/article/detail ...

  10. Zookeeper系统设计的优点

    转自:Zookeeper系统设计的优点.http://webcache.googleusercontent.com/search?q=cache:s6fr40t_5ncJ:www.chaozh.com ...