前言
在调试接口的时候,偶然间在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>
此时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
翻阅其他文章添加数据权限的过滤
@InterceptorIgnore(tenantLine = "true")
添加配置文件
mybatis-plus:
configuration:
shrink-whitespaces-in-sql: true #从SQL中删除多余的空格字符
显然都不行
解决方法
文件借阅 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>
当然,此时查询是不在出现ParseException
异常提示,可以正常查询,但未曾出现借鉴文章中的分页问题。