Mybatis问题BUG集

报错说明1:
org.apache.ibatis.binding.BindingException: Type interface com.jt.mapper.DemoUserMapper is not known to the MapperRegistry.

解决方案:检查.xml映射文件中namespace的值,是否与mapper层中的接口一致

报错说明2:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.jt.mapper.DemoUserMapper.findAll

解决方案:检查.xml映射文件中id的值,是否与mapper层中的接口的方法名一致

报错说明3:
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的值,是否与实体对象路径一致

报错说明4:
org.apache.ibatis.exceptions.PersistenceException: 
Error building SqlSession.
The error may exist in mybatis\mappers\DemoUserMapperh.xml
Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource mybatis\mappers\DemoUserMapperh.xml

解决方案:检查mybatis核心配置文件中加载映射文件的路径是否正确

报错说明5:
org.apache.ibatis.reflection.ReflectionException: There is no getter for property named '18' in 'class com.jt.pojo.DemoUser'

解决方案:如下中18改成age

绑定异常:

<select id="findUserByMap" resultType="User">
    select * from demo_user where age = #{18} and sex = #{sex}
</select>

检查xml映射文件中的namespace
检查xml映射文件中Sql的ID


 3.检查YML文件中xml映射文件的导入
检查YML文件是否定格,是否有层级缩进问题

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值