您好,欢迎来到星星旅游。
搜索
您的当前位置:首页ruoyi-vue整合mybatis-plus分页查询时候出现count()异常

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

来源:星星旅游

项目场景:

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包,主要原因是因为两个版本不一致,代码逻辑不一致导致

具体原因可参考:


解决方案:

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

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

参考:

二:将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>

详情请参考:

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

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- stra.cn 版权所有 赣ICP备2024042791号-4

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务