问题背景
在使用 Mybatis-Plus 开发项目并接入 YashanDB 时,若未正确配置分页插件或数据库方言,可能导致分页功能失效或报错。
推荐配置方式
使用 Oracle 模式配置(推荐):
pagehelper:
helperDialect: oracle
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.ORACLE));
或者使用 MySQL 模式:
pagehelper:
helperDialect: mysql
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
注意事项
插件的方言设置和拦截器 DbType 要保持一致;
控制层建议直接传入 Page 对象,避免业务代码中手动拼接分页 SQL;
避免只创建 Page page = new Page<>() 却未赋值分页参数。
示例代码
Page page = new Page<>(1. 10);
List userList = userMapper.selectPage(page, null).getRecords();
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。