SpringBoot------集成PageHelper分页功能
添加MyBatis的代码,地址
- https://www.cnblogs.com/tianhengblogs/p/9537665.html
修改以下部分:
1.添加MyBatisConfig
- package myshop.config;
- import java.util.Properties;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.Configuration;
- import com.github.pagehelper.PageHelper;
- @Configuration
- public class MyBatisConfig {
- @Bean
- public PageHelper pageHelper()
- {
- System.out.println("Use 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;
- }
- }
2.修改MyBatisController
- package myshop.controller;
- import java.util.List;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import com.github.pagehelper.PageHelper;
- import myshop.bean.UserInfo;
- import myshop.service.MyBatisService;
- @RestController
- public class MyBatisController {
- @Autowired
- private MyBatisService myBatisService;
- @RequestMapping("likeName")
- public List<UserInfo> likeName(String username)
- {
- PageHelper.startPage(1,2);
- return myBatisService.likeName(username);
- }
- }
3.访问地址
- http://localhost:8080/likeName?username=天恒
SpringBoot------集成PageHelper分页功能的更多相关文章
- SpringBoot集成PageHelper时出现“在系统中发现了多个分页插件,请检查系统配置!”
近日在项目中使用SpringBoot集成PageHelper后,跑单元测试时出现了"在系统中发现了多个分页插件,请检查系统配置!"这个问题. 如下图所示: org.mybatis. ...
- Springboot 系列(十二)使用 Mybatis 集成 pagehelper 分页插件和 mapper 插件
前言 在 Springboot 系列文章第十一篇里(使用 Mybatis(自动生成插件) 访问数据库),实验了 Springboot 结合 Mybatis 以及 Mybatis-generator 生 ...
- springboot集成PageHelper,支持springboot2.0以上版本
第一步:pom文件还是需要引入依赖 <!--mybatis的分页插件--> <dependency> <groupId>com.github.pagehelper& ...
- springboot集成pagehelper插件
1.在pom.xml中引入依赖 <dependency> <groupId>com.github.pagehelper</groupId> <artifact ...
- SpringBoot集成Mybatis-PageHelper分页工具类,实现3步完成分页
在Mybatis中,如果想实现分页是比较麻烦的,首先需要先查询出总的条数,然后再修改mapper.xml,为sql添加limit指令. 幸运的是现在已经不需要这么麻烦了,刘大牛实现了一个超牛的分页工具 ...
- springboot + mybatis +pageHelper分页排序
今天下午写查出来的数据的排序,原来的数据没有排序,现在把排序功能加上...原来用的,是xml中的sql动态传参 ,,1个小数没有弄出来,果断放弃... 网上百度一下,发现用pageHelper 可以 ...
- springboot mybatis pagehelper 分页问题
1:添加依赖 compile group: 'com.github.pagehelper', name: 'pagehelper-spring-boot-starter', version: '1.2 ...
- Springboot 使用PageHelper分页插件实现分页
一.pom文件中引入依赖 二.application.properties中配置以下内容(二选一方案) 第一种:pagehelper.helper-dialect=mysqlpagehelper.re ...
- SpringBoot+Mybatis+Pagehelper分页
1.pom.xml <!-- mybatis分页插件 --> <dependency> <groupId>com.github.pagehelper</gro ...
- springboot系列十五、springboot集成PageHelper
一.介绍 项目中经常会遇到分页,PageHelper为我们解决了这个问题.本质上实现了Mybatis的拦截器,作了分页处理. 二.配置PageHelper 1.引入依赖 pagehelper-spri ...
随机推荐
- Mysql5.7主主互备安装配置
一.安装说明 ======================================================================================= 环境: ...
- 首部讲Python爬虫电子书 Web Scraping with Python
首部python爬虫的电子书2015.6pdf<web scraping with python> http://pan.baidu.com/s/1jGL625g 可直接下载 waterm ...
- java操作大文件复制
https://www.cnblogs.com/coprince/p/6594348.html https://blog.csdn.net/w592376568/article/details/796 ...
- WebUpload formdata 上传参数
https://www.cnblogs.com/wisdo/p/6159761.html webUploader 是款很好用的优秀的开源上传组件,由百度公司开发,详细的介绍可参见webUploader ...
- android 判断左右滑动,上下滑动的GestureDetector简单手势检测
直接加入监听GestureDetector放在需要判断滑动手势的地方: import android.app.Activity; import android.os.Bundle; import an ...
- SparkR初体验2.0
突然有个想法,R只能处理百万级别的数据,如果R能运行在Spark上多好!搜了下发现13年SparkR这个项目就启动了,感谢美帝! 1.你肯定得先装个spark吧.看这:Spark本地模式与Spark ...
- GridView Print and Print Preview
sing System.Linq; using System.Printing; using System.Windows; using System.Windows.Controls; using ...
- (笔记)Mysql命令use:使用数据库
use命令可以让我们来使用数据库. use命令格式: use <数据库名>; 例如,如果xhkdb数据库存在,尝试存取它: mysql> use xhkdb;屏幕提示:Datab ...
- python2 python3 字符串 编码格式 处理
使用python的ctypes调用c语言中的函数,传入字符串,打印输出异常.解决方法记录于此. 参考连接: http://blog.csdn.net/u011546806/article/detail ...
- Zookeeper系统设计的优点
转自:Zookeeper系统设计的优点.http://webcache.googleusercontent.com/search?q=cache:s6fr40t_5ncJ:www.chaozh.com ...