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 ...
随机推荐
- WCF 自承载 提供源码
一.WCF 简单介绍 Windows Communication Foundation(WCF)是由微软发展的一组数据通信的应用程序开发接口,是一套通讯接口.现在比较流行的SOA就可以通过WCF实现. ...
- C++标准库 bitset
本文地址:http://www.cnblogs.com/archimedes/p/cpp-bitset.html,转载请注明源地址. 有些程序要处理二进制位的有序集,每个位可能包含 0(关)1(开)值 ...
- SQL Server更改排序规则的实现过程
摘自: http://www.2cto.com/database/201112/115138.html 以下的文章主要向大家描述的是SQL Server更改排序规则的实现过程,以及在实现其实际操作过程 ...
- 关于使用jquery时,ie8下提示对象不支持的属性或方法的解决办法
转自:http://wapapp.baidu.com/auoong/item/538790fcbe87c834d7ff8cde 首先这个问题的前提是已经排除了常见的这个问题.下面说一种今天我碰到的一种 ...
- 关于substring的char[]共享
我们知道,对于一个较大的String对象假设从中获取一个子串.jdk默认子串的char[]是共享原串的char[].即子串的char[]是原串的char[]中的一部分, 这样对于一个原串多个子串的情况 ...
- Activity与Service通信
Activity与Service通信的方式有三种: 继承Binder类 这个方式只有当你的Acitivity和Service处于同一个Application和进程时,才可以用,比如你后台有一个播放背景 ...
- angularjs中响应回车事件
下面这个示例在输入框键入回车键或者点击按钮时,将输入框的值置为"Hello World!":(黄色背景内容为响应回车事件涉及到的代码) <html ng-app=" ...
- Vijos P1002 过河 (NOIP提高组2005)
链接:https://www.vijos.org/p/1002 解析: 若 p*x+(p+1)*y=Q(採用跳跃距离p和p+1时能够跳至不论什么位置Q),则在Q ≥ P*(P-1)时是一定有解的. 因 ...
- vue的全家桶
自定义指令 <div v-demo="{ color: 'white', text: 'hello!' }"></div> Vue.directive('d ...
- Java设计模式(二)-单例模式
单例模式建议保证某个对象仅仅仅仅有一个实例,当仅仅有一个对象来协调整个系统的操作时,在计算机系统中.线程池.缓存.日志对象.对话框.打印机.显卡的驱动程序对象常被设计成单例.总之,选择单例模式就是为了 ...