当前使用版本(必填,否则不予处理)

mybatis-plus.version -> 3.5.2

该问题是如何引起的?(确定最新版也有问题再提!!!)

按照官方文档使用 mybatis-plus 多租户插件,根据条件查询数据库所有表,都用到分页,情况如下:

1、第一种方式,使用xml纯sql方式,报Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "=" "=" 实际输出 : select table_name, table_comment, create_time, update_time from information_schema.tables where table_schema = (select database()) AND table_name NOT LIKE '%xxl_job_%' AND table_name NOT LIKE '%gen_%' AND table_name NOT IN (select table_name from gen_table) order by create_time desc

2、第二种方式,使用 QueryWrapper 拼接sql方式,报Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "=" "=" MyBatis-Plus 使用MybatisPlus提供的多租户插件, 根据条件查询数据库表 报Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: MyBatis-Plus 使用MybatisPlus提供的多租户插件, 根据条件查询数据库表 报Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token:

重现步骤(如果有就写完整)

启用多租户插件,运行如下sql:

select table_name, table_comment, create_time, update_time from information_schema.tables where table_schema = (select database())

报错信息

第一个方式的报错信息: MyBatis-Plus 使用MybatisPlus提供的多租户插件, 根据条件查询数据库表 报Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token:

第二个方式的报错信息 MyBatis-Plus 使用MybatisPlus提供的多租户插件, 根据条件查询数据库表 报Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token:

Comment From: lishuyanla

当取消多租户插件时,测试结果两种方式都是成功的,无报错。

Comment From: miemieYaho

jsqlparser 不支持解析

Comment From: lishuyanla

使用xml纯sql方式也不支持吗?

Comment From: lishuyanla

或者是使用注解方式,过滤特定的方法,排除 SQL 解析

Comment From: miemieYaho

可以加注解不走租户插件

Comment From: lishuyanla

好的,加上 @InterceptorIgnore(tenantLine = "true") 已解决

.