错误示范:
1、首先需要导包,我原本导入的版本是4.1.6,pom文件中导入无法下载,可以在project structure中手动搜索添加
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>4.1.6</version>
</dependency>
2、在spring配置文件中配置sqlSessionFactory中加入以下配置
<property name="plugins"> <array> <bean class="com.github.pagehelper.PageHelper"> <property name="properties">
<!-- 指定方言 --> <value>helperDialect=mysql</value> </property> </bean> </array> </property>
3、使用
PageHelper.startPage(currentPage,pageSize);
然后运行控制台没有错误,当发送请求时,会出现以下错误。是因为pagehelper需要和jsqlparser配合使用
解决方案:
但是由于版本需要配套,最终选用jsqlparser2.0和pagehelper5.1.10
<!-- 分页插件PageHelper -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.10</version>
</dependency>
<dependency>
<groupId>com.github.jsqlparser</groupId>
<artifactId>jsqlparser</artifactId>
<version>2.0</version>
</dependency>
且配置信息需要更换(5以上的版本需要更换,5以下不需要)
<property name="plugins">
<array>
<bean class="com.github.pagehelper.PageInterceptor">
<property name="properties">
<value>helperDialect=mysql</value>
</property>
</bean>
</array>
</property>
最后:
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南