ruoyi-vue整合mybatis-plus分页查询时候出现count()异常

项目场景:

ruoyi-vue整合mybatis-plus详情见:若依官网集成mybatisplus实现mybatis增强

ruoyi-vue 前后端分离版整合mybatis-plus  v3.4.X版本时,查询、删除、修改正常,分页时出现如下异常。


问题描述


### Error querying database.  Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') FROM table_name WHERE (data_status = 0)' at line 1
### The error may exist in com/XXXX/business/mapper/product/ProcurementOrderMapper.java (best guess)
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT COUNT() FROM table_name  WHERE (data_status = ?)
### Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') FROM procurement_order WHERE (data_status = 0)' at line 1


原因分析:

由于ruoyi-vue 集成了 pagehelper分页插件,在进行集成mybatis-plus时候,mybatis-plus 中有jsqlparser jar包,,pagehelper jsqlparser中也有jsqlparser jar包,排除下就可以了。 注意如果有用到mybatis-plus-generator也需要排除jsqlparser jar包,主要原因是因为两个版本不一致,代码逻辑不一致导致

具体原因可参考:mybatis-plus分页查询出现count()问题详细解决过程-CSDN博客


解决方案:

经实测以下解决方案均可:

一:更换版本:V3.4.X版本  ——》3.5.X版本 

参考:mybatis-plus分页报错_mybatisplus分页查询报错-CSDN博客

二:将ruoyi-vue项目中的 pagehelper 依赖排除jsqlparser即可

            <!-- pagehelper 分页插件 -->
            <dependency>
                <groupId>com.github.pagehelper</groupId>
                <artifactId>pagehelper-spring-boot-starter</artifactId>
                <version>${pagehelper.boot.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>com.github.jsqlparser</groupId>
                        <artifactId>jsqlparser</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

详情请参考:mybatis-plus分页查询出现count()问题详细解决过程-CSDN博客

 祝大家生活愉快,工作顺利

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值