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接口的四个开发规范:
- 在mapper.xml中,使namespace等于mapper接口的地址(完全限定名)
- mapper.java接口中的方法名和mapper.xml中statement的id一致
- mapper.java接口中方法的输入参数类型和mapper.xml中statement的parameterType指定的类型一致
- mapper.java接口中方法返回值类型和mapper.xml中statement的resultType指定的类型一致
本文解决了MyBatis中Mapper配置出现的PersistenceException错误,并详细介绍了Mapper接口的正确配置方式及开发规范。
3102

被折叠的 条评论
为什么被折叠?



