spring-boot 集合mybatis 的github分页查询

一、依赖包

 <!-- mysql 数据库驱动. -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency> <!--
spring-boot mybatis依赖: 请不要使用1..0版本,因为还不支持拦截器插件,
1.1.1大家使用最新版本即可
-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.1.</version>
</dependency> <!-- 分页
MyBatis提供了拦截器接口,我们可以实现自己的拦截器,
将其作为一个plugin装入到SqlSessionFactory中。
-->
<!--分页-->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>4.1.</version>
</dependency>

二、加入PageHelper

@Configuration
public class MyBatisConfiguration { @Bean
public 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;
}
}

@SpringBootApplication
@MapperScan("com.fjm.*") //扫描该目录下的文件
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
} }

四、在controller查询方法中加入PageHelper

public List<User> find(Map map)
{
//添加分页查询条件
PageHelper.startPage(0, 2);
return userService.find(null);
}

spring-boot 集合mybatis 的分页查询的更多相关文章

  1. spring boot和mybatis集成分页插件

    MyBatis提供了拦截器接口,我们可以实现自己的拦截器,将其作为一个plugin装入到SqlSessionFactory中. 首先要说的是,Spring在依赖注入bean的时候,会把所有实现MyBa ...

  2. Spring Boot集成MyBatis与分页插件

    Maven依赖: <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>p ...

  3. 【spring boot】14.spring boot集成mybatis,注解方式OR映射文件方式AND pagehelper分页插件【Mybatis】pagehelper分页插件分页查询无效解决方法

    spring boot集成mybatis,集成使用mybatis拖沓了好久,今天终于可以补起来了. 本篇源码中,同时使用了Spring data JPA 和 Mybatis两种方式. 在使用的过程中一 ...

  4. spring boot集成mybatis分页插件

    mybatis的分页插件能省事,本章记录的是 spring boot整合mybatis分页插件. 1.引入依赖 <!-- 分页插件pagehelper --> <dependency ...

  5. spring boot集成mybatis(2) - 使用pagehelper实现分页

    Spring Boot 集成教程 Spring Boot 介绍 Spring Boot 开发环境搭建(Eclipse) Spring Boot Hello World (restful接口)例子 sp ...

  6. Spring Boot 实战 —— MyBatis(注解版)使用方法

    原文链接: Spring Boot 实战 -- MyBatis(注解版)使用方法 简介 MyBatis 官网 是这么介绍它自己的: MyBatis 是一款优秀的持久层框架,它支持定制化 SQL.存储过 ...

  7. Spring boot教程mybatis访问MySQL的尝试

    Windows 10家庭中文版,Eclipse,Java 1.8,spring boot 2.1.0,mybatis-spring-boot-starter 1.3.2,com.github.page ...

  8. spring boot 实现mybatis拦截器

    spring boot 实现mybatis拦截器 项目是个报表系统,服务端是简单的Java web架构,直接在请求参数里面加了个query id参数,就是mybatis mapper的query id ...

  9. spring boot集成mybatis(1)

    Spring Boot 集成教程 Spring Boot 介绍 Spring Boot 开发环境搭建(Eclipse) Spring Boot Hello World (restful接口)例子 sp ...

随机推荐

  1. 文字尺寸、宽高的测量 Paint FontMetrics

    Paint.FontMetrics类简介 Google文档中的描述: ) throw new IndexOutOfBoundsException(); if (bounds == null) thro ...

  2. 【版本】API NDK 系统 分辨率 统计

    Android版本号 版本  API/NDK版本号  代号                        发布时间 7.1.1          25            Nougat      7 ...

  3. C#实现两个数据库之间的数据上报

    用VS2008实现本地数据库上传数据到远程数据.数据能够是一个表,或一个表的部分数据.或查询数据.或数据编辑后上传. 其他VS版本号.复制当中代码就能够.未使用其他不论什么插件.有具体凝视. 单独页面 ...

  4. easyui messager alert 三秒后自动关闭提示

    $.messager.alert(' ','<font size=\"2\" color=\"#666666\"><strong>数据库 ...

  5. (剑指Offer)面试题47:不用加减乘除做加法

    题目: 写一个函数,求两个整数之和,要求在函数体内不得使用+.-.*./四则运算符号. 思路: 很容易想到通过位运算来解决问题. 以5+17=22为例,参考十进制加法:1.只做各位相加不进位运算,即得 ...

  6. 推荐一个在线json数据格式化网站

    json数据非常友好方便的处理: 推荐一个在线json数据格式化网站 http://json.parser.online.fr/

  7. Burning widget

    This is a widget that we can see in Nero, K3B, or other CD/DVD burning software. #!/usr/bin/python # ...

  8. TP框架M方法 create方法丢失字段问题

    TP框架M方法 create方法丢失字段问题! thinkphp框架M方法 create方法丢失字段问题! thinkphp框架M方法 add方法字段丢失问题! 数据库 表新增了字段,用create方 ...

  9. Linux 监测 常用测试工具

    fio [global]bs=16kdirect=1rw=readioengine=libaioiodepth=6write_bw_logruntime=60[test]filename=/data/ ...

  10. ant design pro (四)新增页面

    一.概述 参看地址:https://pro.ant.design/docs/new-page-cn 这里的『页面』指配置了路由,能够通过链接直接访问的模块,要新建一个页面,通常只需要在脚手架的基础上进 ...