添加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分页功能的更多相关文章

  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. (Hive)史上最难解析的json字符串解析出来了!!

    首先说下解析的数据如下: {"username":"king","actionInfo":{"id":1,"a ...

  2. javascript 完美解决对联广告

    javascript 完美解决对联广告 // function couplet(){ if(arguments.length>=1) this.objID = document.getEleme ...

  3. Extjs4.2 Grid搜索Ext.ux.grid.feature.Searching的使用

    背景 Extjs4.2 默认提供的Search搜索,功能还是非常强大的,只是对于国内的用户来说,还是不习惯在每列里面单击好几下再筛选,于是相当当初2.2里面的搜索,更加的实用点,于是在4.2里面实现. ...

  4. Docker run 命令的使用方法

    [编者的话]在Docker中,run应该是用户使用最多的命令了,很多读者反馈不是很明白run命令的用法,而且相关的书籍.中文资料中对run命令的描述也不是非常完整,所以DockerOne组织翻译了Do ...

  5. 创建Maven项目出错

    有时候创建maven项目的时候会出错,例如在创建Spring cloud 2 项目的时候,会出现org.apache.maven.archiver.MavenArchiver.getManifest( ...

  6. 安卓程序代写 网上程序代写[原]C语言基础

    C 作者:han1202012 发表于2013-11-1 19:53:29 原文链接 阅读:28 评论:0 查看评论

  7. Sword STL仿函数示例

    一元函数 unary_function .有返回值. .只有一个参数. template <class Arg, class Result> struct unary_function { ...

  8. 基础 | batchnorm原理及代码详解

    https://blog.csdn.net/qq_25737169/article/details/79048516 https://www.cnblogs.com/bonelee/p/8528722 ...

  9. 解决maven jmxtools 缺失的问题

    原因:有版权,所以maven仓库基本都下架了jmxtool. 目前可用的,我就找到了wso2这家,配置如下: <project xmlns="http://maven.apache.o ...

  10. 第三百六十四节,Python分布式爬虫打造搜索引擎Scrapy精讲—elasticsearch(搜索引擎)的mapping映射管理

    第三百六十四节,Python分布式爬虫打造搜索引擎Scrapy精讲—elasticsearch(搜索引擎)的mapping映射管理 1.映射(mapping)介绍 映射:创建索引的时候,可以预先定义字 ...