SpringBoot自我整理学习3(springboot集成Mybatis+PageHelp分页插件)
来源:互联网 发布:淘宝网上怎么买药 编辑:程序博客网 时间:2024/05/18 14:28
1)首先需要引入依赖包
<dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.3.1</version></dependency> <!-- mybatis 分页插件 --> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>4.1.6</version> </dependency>
1)首先先说明集成mybtais,配置挺简单的
################################################## 整合Mybatis ####### ################# 加载Mybatis的相关配置 ################mybatis: ########### 扫描mapper的配置 ######### mapper-locations: classpath:mapper/*Mapper.xml ######### mybatis额外的一些配置信息 ####### config-location: classpath:mybatis/mybatis-config.xml #### 扫描实体 可以直接用类名 不需要加全路径### type-aliases-package: com.sxs.entity
然后启动项目,访问一些地址,以我的案例说明:
访问后,我的控制台打印出了3,这个表示有3条数据(我的数据库里面就3条记录)
2)介绍使用PageHelp的分页插件
2.1)配置个分页插件的配置
相关代码如下,具体什么意思,找度娘。
@Configurationpublic class MybatisConfigurationConfig { @Bean public PageHelper pageHelper(){ PageHelper pageHelper=new PageHelper(); Properties properties=new Properties(); properties.setProperty("offsetPageNum","true"); properties.setProperty("rowBoundsWithCount", "true"); properties.setProperty("reasonable", "true"); pageHelper.setProperties(properties); return pageHelper; }}
然后就可以在原来的查询地方之前使用了,参考如下:
启动项目,再次执行这个请求,发现控制打印的是2,说明分页有效。
说明:关于mybatis和分页的配置,网上也有很多,配置的方式很多种,根据自己的业务进行配置即可。
阅读全文
0 0
- SpringBoot自我整理学习3(springboot集成Mybatis+PageHelp分页插件)
- SpringBoot自我整理学习2(springboot集成Druid)
- springBoot集成pageHelp
- SpringBoot学习-支持PageHelp插件使用
- SpringBoot学习笔记之mybatis分页插件集成
- SpringBoot集成MyBatis的分页插件PageHelper
- SpringBoot自我整理学习1(springboot入门)
- Gradle构建SpringBoot+Mybatis集成分页插件PageHelper
- SpringBoot集成MyBatis的分页插件PageHelper(回头草)
- SpringBoot集成分页插件PageHelper
- SpringBoot 极简MyBatis分页插件
- springboot +mybatis + pagehelper分页插件
- SpringBoot学习3之数据库集成mybatis
- SpringBoot学习(二)--集成mybatis+freemark
- SpringBoot学习-(七)SpringBoot分页插件PageHelper
- SpringBoot+Maven项目实战(5):集成分页插件
- SpringBoot集成通用Mapper 分页插件 Generator
- 二十一、SpringBoot整合Mybatis、通用mapper和pageHelp
- C#遇到的一些问题与解决方法
- 【传智播客郑州校区分享】来聊聊UI里面哪些颜色看起来高大上
- 使用PageOffice实现文档(word,excel,pdf)在线预览编辑
- 2.2 分别定义int,short类型的变量各一个,并依次输出它们的存储空间大小
- 如何理解语言
- SpringBoot自我整理学习3(springboot集成Mybatis+PageHelp分页插件)
- TensorFlow快速入门
- 挑战程序设计 DP POJ 3181
- [学习笔记]Python基础_安装和环境配置
- 用户画像越完整,用户本人越遭殃
- Linux-IDE编译工具的开发介绍
- IQActionSheetPickerView
- java并发-java内存模型(6)
- 网狐荣耀棋牌最新版源码下载