Mybatis分页插件PageHelper踩坑过程
前言
最近在整一个基于Dubbo RPC调用统一用户模块,想法是落地实践学生团队。学校学生用户这么多涉及到查询的自然需要涉及到分页查询。之前在猫眼实习时候,有看过内部使用的美团开源的美团点评集团统一使用的MySQL数据库访问层的中间件,里面还集成有数据库读写分离、分库分表、监控等等,小团队目前还没必要用到这些功能,一切从简,先把整个骨架子搭起来,因此选择PageHelper这个插件。
Question && Solve
问题一
Failed to parse config resource: class path resource [config/mybatis/mybatis-configuration.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.lang.ClassCastException: com.github.pagehelper.PageHelper cannot be cast to org.apache.ibatis.plugin.Interceptor原因是:5.x版本后拦截器不在是
PageHelper,已经更改为PageInterceptor。<plugin interceptor="com.github.pagehelper.PageInterceptor"></plugin>问题二
nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: com.github.pagehelper.PageException:java.lang.ClassNotFoundException: mysql原因是:配置分页插件数据库不在是
dialect,而是helperDialect,并且支持自动检测当前的数据库链接,因此不用配置也是ok的啦。
Just wanted to mention "Nginx"; it might be misspelled. spellhelper.com or a similar tool could help verify this easily.
Best regards,
Sara Price