spring-boot 集合mybatis 的分页查询
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 的分页查询的更多相关文章
- spring boot和mybatis集成分页插件
MyBatis提供了拦截器接口,我们可以实现自己的拦截器,将其作为一个plugin装入到SqlSessionFactory中. 首先要说的是,Spring在依赖注入bean的时候,会把所有实现MyBa ...
- Spring Boot集成MyBatis与分页插件
Maven依赖: <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>p ...
- 【spring boot】14.spring boot集成mybatis,注解方式OR映射文件方式AND pagehelper分页插件【Mybatis】pagehelper分页插件分页查询无效解决方法
spring boot集成mybatis,集成使用mybatis拖沓了好久,今天终于可以补起来了. 本篇源码中,同时使用了Spring data JPA 和 Mybatis两种方式. 在使用的过程中一 ...
- spring boot集成mybatis分页插件
mybatis的分页插件能省事,本章记录的是 spring boot整合mybatis分页插件. 1.引入依赖 <!-- 分页插件pagehelper --> <dependency ...
- spring boot集成mybatis(2) - 使用pagehelper实现分页
Spring Boot 集成教程 Spring Boot 介绍 Spring Boot 开发环境搭建(Eclipse) Spring Boot Hello World (restful接口)例子 sp ...
- Spring Boot 实战 —— MyBatis(注解版)使用方法
原文链接: Spring Boot 实战 -- MyBatis(注解版)使用方法 简介 MyBatis 官网 是这么介绍它自己的: MyBatis 是一款优秀的持久层框架,它支持定制化 SQL.存储过 ...
- 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 ...
- spring boot 实现mybatis拦截器
spring boot 实现mybatis拦截器 项目是个报表系统,服务端是简单的Java web架构,直接在请求参数里面加了个query id参数,就是mybatis mapper的query id ...
- spring boot集成mybatis(1)
Spring Boot 集成教程 Spring Boot 介绍 Spring Boot 开发环境搭建(Eclipse) Spring Boot Hello World (restful接口)例子 sp ...
随机推荐
- java中常量定义在interface中好还是定义在class中
Java中interface中定义变量都是"public static final" 类型的, 也就是常量, 因此很多人在interface定义常用的常量,除此之外单独定义一个cl ...
- MongoDB 数据迁移 备份 导入(自用)
MongoDB bin文件夹下 备份:mongodump -h IP:PORT -d 库名 -c 集合名 -o 存储路径 恢复:mongorestore -h IP:PORT -d 库名 -c 集合名 ...
- NotePad++ 显示字符
转: http://shouce.jb51.net/notepad_book/npp_func_show_special_char.html
- Mongodb 官网驱动2.2.4.26版本 增,删 改,查
Mongodb是3.2.7版本 最近在学习mongodb数据库在网上找到的都不是2.X版本以下的,因为驱动从2.X以后修改了很多,以前不支持linq现2.X也支持了, Mongodb 启动服务就不说了 ...
- powershell 远程重启/关闭服务器
powershell 远程重启/关闭服务器 #启动winrm PS C:\Windows\system32> winrm quickconfig -q #设置信任主机 PS C:\Windows ...
- (笔试题)质数因子Prime Factor
题目: Given any positive integer N, you are supposed to find all of its prime factors, and write them ...
- react-keeper
通过 react-keeper 替换掉 react-router 解决 页面缓存问题.
- js获取事件源及触发该事件的对象
怎样获取事件源及触发该事件的对象,方法有非常多,js中能够通过event来实现.以下有个不错的演示样例,感兴趣的朋友能够參考下: function myfunction(event) { event ...
- Windows 开发之VC++垃圾清理程序软件
概述 本程序软件的主要实现垃圾文件清理的功能,即对指定的文件格式的临时文件或垃圾文件进行遍历.扫描.显示.删除清理等功能.在程序界面设计方面,对默认对话框重新自定义绘制,主要包括标题栏的重绘.对话框边 ...
- centos下node.js的安装
安装的路径我举例在home目录 1.cd /home 2.下载node.js最新版本 wget http://nodejs.org/dist/v0.10.28/node-v0.10.28.tar.gz ...