今天用pagehelper时分页碰到了以下问题
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: 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 0,3' at line 2
### The error may exist in com/cyf/mapper/UserMapper.xml
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: select * from user; limit ?,?
### Cause: 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 0,3' at line 2
结果是mapper.xml文件中sql语句出现问题
因为默认调用的是selectAll方法
<select id="selectAll" resultType="user">
select *
from user;
</select>
这里面加了分号,所以会报错,所以建议在写sql语句结束时不要加分号