当前使用版本(必填,否则不予处理)
<!-- https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-boot-starter -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.4</version>
</dependency>
该问题是如何引起的?(确定最新版也有问题再提!!!)
使用 MyBatis Plus 进行查询时 sql 自动在查询语句(SELECT ...)后加了 ; 分号,导致 LIMIT 语句报错。
重现步骤(如果有就写完整)
报错信息
org.springframework.jdbc.BadSqlGrammarException:
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 'LIMIT 2,2' at line 17
The error may exist in com/geek/demo/geek_java/mapper/INewTableGeekMapper.xml
The error may involve com.geek.demo.geek_java.mapper.INewTableGeekMapper.selectList-Inline
The error occurred while setting parameters
SQL: SELECT id, unique_id, var_char, char_db, int_db, big_int, db_insert_time, db_update_time, db_deleted FROM new_table_geek WHERE db_deleted = 0; LIMIT ?,?
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 'LIMIT 2,2' at line 17
; bad SQL grammar []; nested exception is 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 'LIMIT 2,2' at line 17
Comment From: miemieYaho
排查你的配置在哪里多个;,那么多人用不可能就你遇到这种bug的
Comment From: lyfGeek
这个 default