java.lang.Exception: No tests found matching [{ExactMatcher:fDisplayName=FindUserByUsername], {ExactMatcher:fDisplayName=FindUserByUsername(top.gclmit.test.JunitTest)], {LeadingIdentifierMatcher:fClassName=top.gclmit.test.JunitTest,fLeadingIdentifier=FindUserByUsername]] from org.junit.internal.requests.ClassRequest@579bb367
错误原因:在 junit 测试中忘记在测试单元上添加@Test
报错信息
1
2
3
4
5
6
org.apache.ibatis.exceptions.PersistenceException:
### Error updating 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 ') values('贱人','2017-10-10 10:39:10.119','hky','男')' at line 1
### The error may involve User.insertUser-Inline
### The error occurred while setting parameters
### SQL: insert into user (username,birthday,address,sex,) values(?,?,?,?)
### 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 ') values('贱人','2017-10-10 10:39:10.119','hky','男')' at line 1
错误原因: 自己不小小心,再 User.xml 中的 sql 语句中多加了一个逗号
报错信息
1
2
3
4
5
6
org.apache.ibatis.exceptions.PersistenceException:
### Error updating database. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'birthdy' in 'class top.gclmit.pojo.User'
### The error may involve User.updateUserById-Inline
### The error occurred while setting parameters
### SQL: update user set username = ?,birthdy=?,address=?,sex=? where id=?
### Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'birthdy' in 'class top.gclmit.pojo.User'
错误原因: 实体类 User 中不存在 birthdy。经检查发现变量 birthday 打错了.
报错信息
1
2
3
4
org.apache.ibatis.exceptions.PersistenceException:
### Error building SqlSession.
### The error may exist in sqlmap/User.xml
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias ''. Cause: java.lang.ClassNotFoundException: Cannot find class:
错误原因: User.xml 文档中有个 sql 语句没写完。
报错信息
1
2
3
4
5
6
org.apache.ibatis.exceptions.PersistenceException:
### Error updating 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 'user where id = 29' at line 1
### The error may involve User.deleteUserById-Inline
### The error occurred while setting parameters
### SQL: delete form user where id = ?
### 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 'user where id = 29' at line 1
错误原因: delete form user where id = ? sql 语句书写错误,正确应为 delete from user where id = ?
报错信息
1
org.apache.ibatis.binding.BindingException: Type interface top.gclmit.mapper.UserMapper is not known to the MapperRegistry.
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: Could not set property 'userId' of 'class top.gclmit.pojo.User' with value '1' Cause: org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'userId' in 'class top.gclmit.pojo.User'
### The error may exist in top/gclmit/mapper/OrderMapper.xml
### The error may involve top.gclmit.mapper.OrderMapper.selectOrders
### The error occurred while handling results
### SQL: select o.id, o.user_id, o.number, o.createtime, u.username from orders o left join user u on o.user_id=u.id
### Cause: org.apache.ibatis.reflection.ReflectionException: Could not set property 'userId' of 'class top.gclmit.pojo.User' with value '1' Cause: org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'userId' in 'class top.gclmit.pojo.User'