mybatis问题BUG集
作者:互联网
报错说明1:
org.apache.ibatis.binding.BindingException: Type interface com.jt.mapper.UserMapper is not known to the MapperRegistry.
解决方案1:
检查namespace命名是否与接口一致
报错说明2:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.jt.mapper.UserMapper.findAll
解决方案2:
检查xml映射文件中的ID是否与接口方法一致.
报错说明3:
The error may exist in mybatis/mappers/UserMapper2.xml
解决方案3:
检查mybatis核心文件加载mapper映射文件的路径是否正确.
报错说明4:
Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is ‘mybatis/mappers/demoUserMapper.xml’. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘DemoUser’. Cause: java.lang.ClassNotFoundException: Cannot find class: DemoUser
解决方案4:
问题可能是xml映射文件中的resultType的类型异常.
报错说明5:
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'from demo_user where sex = '女' and age < 100' at line 1
### The error may exist in mybatis\mappers\demoUserMapper.xml
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: select from demo_user where sex = ? and age < ?
### Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'from demo_user where sex = '女' and age < 100' at line 1
解决方案5:
问题是sql语句错误
报错说明6:
org.apache.ibatis.exceptions.PersistenceException:
### Error building SqlSession.
### The error may exist in mybatis\mappers\DemoUserMapper.xml
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'mybatis\mappers\DemoUserMapper.xml'. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.jt.pojo.DemoUserp'. Cause: java.lang.ClassNotFoundException: Cannot find class: com.jt.pojo.DemoUserp
解决方案:检查.xml映射文件中resultType的值,是否与实体对象路径一致
标签:xml,ibatis,问题,apache,mybatis,org,Cause,BUG,### 来源: https://blog.csdn.net/wohaoniua/article/details/120481403