一、场景
1、对接民航电子数据库
2、代码执行到PageHelper.startPage()
时报错
二、报错信息
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: com.github.pagehelper.PageException: 无法自动获取数据库类型,请通过 helperDialect 参数指定!
### Cause: com.github.pagehelper.PageException: 无法自动获取数据库类型,请通过 helperDialect 参数指定!
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
at sun.reflect.GeneratedMethodAccessor176.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
... 136 common frames omitted
Caused by: com.github.pagehelper.PageException: 无法自动获取数据库类型,请通过 helperDialect 参数指定!
at com.github.pagehelper.page.PageAutoDialect.getDialect(PageAutoDialect.java:217)
at com.github.pagehelper.page.PageAutoDialect.initDelegateDialect(PageAutoDialect.java:99)
at com.github.pagehelper.PageHelper.skip(PageHelper.java:66)
at com.github.pagehelper.PageInterceptor.intercept(PageInterceptor.java:93)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)
at com.sun.proxy.$Proxy528.query(Unknown Source)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
... 141 common frames omitted
三、原因
无法自动获取数据库类型,请通过 helperDialect 参数指定!
四、解决
在application
配置文件添加以下配置即可
pagehelper:
#本例中对接的民航电子数据库是兼容mysql的,所以这里直接指定mysql
helper-dialect: mysql