Type interface mapper.UserMapper is not known to the MapperRegistry.

本文解决了MyBatis中Mapper配置出现的PersistenceException错误,并详细介绍了Mapper接口的正确配置方式及开发规范。

org.apache.ibatis.exceptions.PersistenceException:

### Error building SqlSession.
### The error may exist in mybatis/mapper/UserMapper.xml

org.apache.ibatis.binding.BindingException: Type interface mapper.UserMapper is not known to the MapperRegistry.


在学习mybatis的过程中遇到了以上相关的问题,最后解决办法是:



UserMapper.xml中的namespace 要和全局配置文件中注册的路径一样。

————————————————————————————————————————————————————————————————

下面附上网上查找的编写mapper接口的四个开发规范:

  1. 在mapper.xml中,使namespace等于mapper接口的地址(完全限定名)
  2. mapper.java接口中的方法名和mapper.xml中statement的id一致
  3. mapper.java接口中方法的输入参数类型和mapper.xml中statement的parameterType指定的类型一致
  4. mapper.java接口中方法返回值类型和mapper.xml中statement的resultType指定的类型一致

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值