錯誤示范:
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>
最后:

浙公網安備 33010602011771號