Spring Boot 之 Mybatis Plus 分页插件
- 加依赖
<!--mybatis-plus-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
- 在application.yml中加入mybatis-plus的配置信息
mybatis-plus:
mapper-locations: classpath:/mapper/*.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
type-aliases-package: com.atguigu.gmall.product.entity
- 创建分页插件所在的类MybatisPlusConfiguration,并添加注解
@Configuration
- 在配置类中添加以下代码
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
/**
* MybatisPlusInterceptor是插件主体,管理所有的插件
*/
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
/**
* 创建分页插件
*/
PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
/**
* 溢出总页数后按最大页处理
*/
paginationInnerInterceptor.setOverflow(true);
//把分页插件设置给插件主体
interceptor.addInnerInterceptor(paginationInnerInterceptor);
return interceptor;
}
作者:摆烂ing
出处:http://www.cnblogs.com/insilently/
版权:本文版权归作者所有
转载:欢迎转载,但未经作者同意,必须保留此段声明;必须在文章中给出原文连接;否则必追究法律责任
出处:http://www.cnblogs.com/insilently/
版权:本文版权归作者所有
转载:欢迎转载,但未经作者同意,必须保留此段声明;必须在文章中给出原文连接;否则必追究法律责任
分类:
Spring Boot
, Mybatis Plus
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!