pagehelper-spring-boot
pagehelper-spring-boot copied to clipboard
分页返回总记录数(total)有问题
版本信息:
Spring-Boot:1.5.8.RELEASE
mybatis-spring-boot-starter:1.3.1
pagehelper-spring-boot-starter:1.2.3
配置信息如下:
-
pagehelper.helperDialect=oracle 有分页,但是,总数(total)不对,显示的是pageSize的大小
-
pagehelper.helperDialect=com.github.pagehelper.dialect.helper.OracleDialect 有分页,但是,总数(total)不对,显示的是pageSize的大小
-
pagehelper.Dialect=com.github.pagehelper.dialect.helper.OracleDialect 没有分页,查询的是全部数据,但是总数(total)是对的
-
pagehelper.Dialect=oracle 报错:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration': Invocation of init method failed; nested exception is com.github.pagehelper.PageException: java.lang.ClassNotFoundException: oracle
pagehelper.helperDialect=oracle
这个是对的。
第二个配置也对。
你用PageInfo了吗?你比较的total和pageSize是基于Page还是PageInfo?
在PageInfo中,如果构造参数传入的不是Page类型,就会当成List,然后total=list.size()
所以你需要通过日志判断,你的查询是否真正经过了count和分页查询。
出问题的兄弟 你是不是用了dubbo这种分布式的东西了
兄弟 , 是不 把 pagehelper.default-count=true 设置成 false 了。 设置成false 就变成-1 了。
还有一种情况, 就是 java代码里用了pagehelper, 但是xml里没有配置插件