zoukankan      html  css  js  c++  java
  • 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即可。
    开启打怪升级之旅
  • 相关阅读:
    TSQL笔记4:表
    C#笔记26: 与非托管代码交互操作
    C#笔记22:多线程之停止或取消线程
    C#笔记25:比较和排序(IComparable和IComparer以及它们的泛型实现)
    TSQL笔记7:临时表和表变量
    TSQL笔记6:GO
    WPF快速指导9:WPF中的属性(依赖项属性)
    TSQL笔记2:INSERT、UPDATE和DELETE
    C#笔记23:多线程之Task(并行编程)
    云计算读书笔记(一)
  • 原文地址:https://www.cnblogs.com/zhangliwei/p/9575867.html
Copyright © 2011-2022 走看看