pagehelper使用报SQL语句异常
- 今天在使用pagehelper时候,写完之后出现一个异常
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 4’ at line 1 - 猜想pagehelper的工作原理应该就是先把sql字符串拼接于是果断看Mapper.xml里面的sql语句发现后边有个分号
- 于是猜想可能是pagehelper拼劲的字符加到了分号后边,自然就会报错
- 删去分号测试成功
总结:去掉分号,在以后写sql语句时候应该也尽量避免写分号