日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

SpringBoot、mysql配置PageHelper插件

發布時間:2023/12/13 数据库 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SpringBoot、mysql配置PageHelper插件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一:https://blog.csdn.net/h985161183/article/details/79800737

主要異常:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration':?

pageHelper.jar版本與MyBatis版本不兼容;換用高版本jar包

我用的SpringBoot版本:

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

pageHelper版本:

<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.5</version>
</dependency>

二:https://blog.csdn.net/s592652578/article/details/78179998

主要異常信息:com.github.pagehelper.PageHelper cannot be cast to org.apache.ibatis.plugin.Interceptor
我的配置

<plugins>
  <plugin interceptor="com.github.pagehelper.PageHelper">
  <!-- 設置數據庫類型 Oracle,Mysql,MariaDB,SQLite,Hsqldb,PostgreSQL六種數據庫-->
  <property name="dialect" value="mysql"/>
  </plugin>
</plugins>

解決:配置中實現的是com.github.pagehelper.PageHelper這個接口,而錯誤報的是這個借口在強轉成org.apache.ibatis.plugin.Interceptor這個借口的時候報錯了,而我使用的是pageheper5.1.2版本,上網一查,自4.0.0版本以后就不再實現這個接口了,轉而實現這個接口:org.apache.ibatis.plugin.Interceptor,因此,修改配置如下:

<plugins>
  <plugin interceptor="com.github.pagehelper.PageInterceptor">
  <!-- 設置數據庫類型 Oracle,Mysql,MariaDB,SQLite,Hsqldb,PostgreSQL六種數據庫-->?
  <property name="dialect" value="mysql"/>
  </plugin>
</plugins>

又報異常:主要是mysql類不識別,最終原因還是因為版本的問題,自4.0.0以后的版本已經可以自動識別數據庫了,所以不需要我們再去指定數據庫,所以,修改配置: <plugins>
  <plugin interceptor="com.github.pagehelper.PageInterceptor">
  </plugin>
</plugins> 三:之后的異常:java.lang.RuntimeException: 在系統中發現了多個分頁插件,請檢查系統配置!

刪除mybatis-config.xml文件中的pagehelper就好了 <!--<plugins>-->
<!--&lt;!&ndash; com.github.pagehelper為PageHelper類所在包名 &ndash;&gt;-->
<!--<plugin interceptor="com.github.pagehelper.PageInterceptor">-->
<!--</plugin>-->
<!--</plugins>-->

https://blog.csdn.net/boke7265/article/details/80863010

總結:SpringBoot、mysql配置PageHelper插件,只需要使用 2.0.4.RELEASE版本SpringBoot引入1.2.5版本pageHelper即可。

轉載于:https://www.cnblogs.com/zhangliwei/p/9575867.html

總結

以上是生活随笔為你收集整理的SpringBoot、mysql配置PageHelper插件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。