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 ...
随机推荐
- IIS 7上部署PHP
前言 前段时间整了一个挂Q的平台.源代码是从网上下载的,后期稍微调整了一下链接和title之类的文字就上线了.详细在这里. 运行了一段时间,除了偶尔出现QQ下线上线,整体效果基本上符合预期,个人感觉很 ...
- docker安装及加速配置
需要centos7版本,内核版本不低于3.10 [root@localhost ~]# uname -r3.10.0-514.el7.x86_64 第一步:更新当前软件:[root@localhost ...
- android批量插入数据效率对比
对比在android中批量插入数据的3中方式对比(各插入1W条数据所花费的时间): 1. 一个一个插入 /** * 向表中插入数据 * * @param openHelper * @param app ...
- getDimension()、getDimensionPixelOffset()和getDimensionPixelSize()区别详解
getDimension()是基于当前DisplayMetrics进行转换,获取指定资源id对应的尺寸.文档里并没说这里返回的就是像素,要注意这个函数的返回值是float,像素肯定是int. getD ...
- Linux强制杀进程命令行工具
需求, 有时候我们会有手动启动程序, 但是又在后台, 没有像服务那样有start, 和stop的程序, 这时候需要用强制杀进程方式 涉及工具, awk, sed, xargs, kill 需求一: 已 ...
- vscode 自定义快捷键
vscode 自定义快捷键 这两天用vscode写了下Python,感觉很舒服,只是快捷键不如人意,略作修改,放上来作为备份.smile~ 主要更改: 代码格式化 ctrl+alt+l 执行代码 ct ...
- Mac 下 Homebrew(类似CentOS下的yum)简介及安装
Homebrew官网 http://brew.sh/index_zh-cn.html Homebrew是神马 linux系统有个让人蛋疼的通病,软件包依赖,好在当前主流的两大发行版本都自带了解决方案, ...
- (转)Live555单线程原理
1. 概述 在live555-Server库中,使用单线程实现了多用户请求视频数据,这似乎多线程才能实现的功能,并且用户请求视频数据各个流程衔接的都十分完美,其执行效率非常高. live555是如何实 ...
- ProGuard代码混淆详细攻略
转载请标明出处:http://blog.csdn.net/shensky711/article/details/52770993 本文出自: [HansChen的博客] ProGuard简介和工作流程 ...
- idea中maven导入jar包
导入servlet和jsp的jar包 要想在pom.xml中配置一个依赖,必须要知道这个依赖库的坐标:groupId,artifacatId,version 1.可以通过查阅依赖库的资料获取坐标,然后 ...