项目场景:spring-boot整合通用mapper
问题描述:
Caused by: 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 'order ( id,total_num,total_money,pay_money,pay_type,create_time,update_time,use' at line 1
原因分析:
通用mapper直接生成的sql语句报语法错误
利用mybatis log插件查看sql
将sql语句copy到Navicat 中执行
INSERT INTO order ( id,total_num,total_money,pay_money,pay_type,create_time,update_time,username,buyer_rate,source_type,order_status,pay_status,consign_status ) VALUES( '1322732101556027392',4,383600,383600,'1','2020-11-01 10:48:02.842','2020-11-01 10:48:02.842','heima','0','1','0','0','0' );
报同样错误
[Err] 1064 - 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 'ORDER (
id,
total_num,
total_money,
pay_money,
pay_type,
create_time' at line 1
后来仔细一看,发现表名order是大写,于是想到order是关键字,问题找到了
解决方案:
将对应实体类上@Table注解里对应的表名改为(name="`order`")即可,注意 ` 是table键上面的那个符号
======>
问题解决.