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

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的过程中遇到了以上相关的问题,最后解决办法是:

Type interface mapper.UserMapper is not known to the MapperRegistry._第1张图片

Type interface mapper.UserMapper is not known to the MapperRegistry._第2张图片

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指定的类型一致

你可能感兴趣的:(JAVA)