mybatisplus自带分页方法无分页效果
mybatisplus自带分页方法无分页效果
·
1、如果没有自定义SqlSessionFactory类,加配置类即可
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor(){
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
//添加分页插件
PaginationInnerInterceptor pageInterceptor = new PaginationInnerInterceptor();
//设置请求的页面大于最大页的操作,true调回首页,false继续请求,默认是false
pageInterceptor.setOverflow(false);
//单页分页的条数限制,默认五限制
pageInterceptor.setMaxLimit(500L);
//设置数据库类型
pageInterceptor.setDbType(DbType.MYSQL);
interceptor.addInnerInterceptor(pageInterceptor);
return interceptor;
}
2、如果自定义了SqlSessionFactory类,在配置中加分页插件。
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
//添加分页插件
PaginationInnerInterceptor pageInterceptor = new PaginationInnerInterceptor();
pageInterceptor.setDbType(DbType.MYSQL);
interceptor.addInnerInterceptor(pageInterceptor);
sessionFactory.setPlugins(interceptor);

完美解决:

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐




所有评论(0)