mybatis-plus分页和pagehelper冲突(java.lang.NoSuchMethodError: net.sf.jsqlparser.statement.select.Plain)

1.背景:

以前一直用的mybatis,用pagehelper做分页,后来引用了mybatis-plus,以前pagehelper做的分页突然就都报错了。

java.lang.NoSuchMethodError: net.sf.jsqlparser.statement.select.PlainSelect.getGroupByColumnReferences()Ljava/util/List;

以前引用

<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper-spring-boot-starter</artifactId>
    <version>1.2.10</version>
    <exclusions>
        <exclusion>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>*</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-core</artifactId>
    <version>3.2.0</version>
</dependency>

2.查看引用的包发现:

pagehelper5.1.8里面用的jsqlparser用的版本为1.2

而mybatis-plus-core 3.2.0里面用的jsqlparser版本是2.1

只有低版本的jsqlparser里面才有getGroupByColumnReferences这个方法

jsqlparser版本不一致,发现pagehelper5.1.10用的jsqlparser版本为2.0,将pagehelper版本升级

<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper</artifactId>
    <version>5.1.10</version>
</dependency>
<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-core</artifactId>
    <version>3.2.0</version>
</dependency>

 

经测试,使用的pagehelper没有报错,但是可能分页无效

将mybatisConfig.xml中配置如下即可正常使用

<plugins>
    <!--mybatisplus分页配置-->
    <plugin interceptor="com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor">
    </plugin>
    <!--pagehelper分页配置-->
    <plugin interceptor="com.github.pagehelper.PageInterceptor">
    </plugin>
</plugins>

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值