当前位置:   article > 正文

MyBatis-PLUS net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: “,“ “,“

net.sf.jsqlparser.parser.parseexception: encountered unexpected token: "grou

文章目录

前言

在调试接口的时候,偶然间在mapper文件中查询数据库出现了如下提示

net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "," ","
 at line 8, column 38.
Was expecting one of:
";" 
"CONNECT"
"EMIT"
"GROUP"
"HAVING"     
"INTO"     
"START"     
"WINDOW"     
<EOF>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

此时sql语句中也未曾出现关键字之类的

select log.* from table1 log
join table2 a on log.aid = a.id
left join table3 b on log.bId = b.id
order by log.create_time desc
  • 1
  • 2
  • 3
  • 4

翻阅其他文章添加数据权限的过滤

@InterceptorIgnore(tenantLine = "true")
  • 1

添加配置文件

mybatis-plus:
  configuration:
    shrink-whitespaces-in-sql: true #从SQL中删除多余的空格字符 
  • 1
  • 2
  • 3

显然都不行

解决方法

文件借阅 gitee mybatis-plus版本问题
该项目中未曾配置过其他分页插件,所以也不存在分页插件冲突
MyBatis-Plus-3.5.2 同样也默认依赖 JSqlParser-4.4,而 JSqlParser-4.4 在解析SQL时,存在bug,导致报错,升级为 JSqlParser-4.6 后,问题将被解决

 <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.2</version>
            <exclusions>
                <!-- 解决jsqlparser 依赖版本解析问题-->
                <exclusion>
                    <artifactId>jsqlparser</artifactId>
                    <groupId>com.github.jsqlparser</groupId>
                </exclusion>
            </exclusions>
        </dependency>
       
        <dependency>
            <groupId>com.github.jsqlparser</groupId>
            <artifactId>jsqlparser</artifactId>
            <version>4.6</version>
        </dependency>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

当然,此时查询是不在出现ParseException异常提示,可以正常查询,但未曾出现借鉴文章中的分页问题。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/894176
推荐阅读
相关标签
  

闽ICP备14008679号