Mybatis:Type interface cn.itsun.dao.UserDao is not known to the MapperRegistry

Exception in thread “main” org.apache.ibatis.binding.BindingException: Type interface com.zsd.dao.IUserDao is not known to the MapperRegistry.
at org.apache.ibatis.binding.MapperRegistry.getMapper(MapperRegistry.java:47)
at org.apache.ibatis.session.Configuration.getMapper(Configuration.java:763)
at org.apache.ibatis.session.defaults.DefaultSqlSession.getMapper(DefaultSqlSession.java:291)
at com.zsd.test.MybataisTest.main(MybataisTest.java:28)

1. 实际目录不正确

Mybatis:Type interface cn.itsun.dao.UserDao is not known to the MapperRegistryMybatis:Type interface cn.itsun.dao.UserDao is not known to the MapperRegistry

<mapper namespace=“com.zsd.dao.IUserDao”>和IUserDao类的路径地址看上去一样。
因为idea的java路径下的包是可以用 "."来表示目录的下一级。但是我们实际看下文件路径。
Mybatis:Type interface cn.itsun.dao.UserDao is not known to the MapperRegistry
文件夹名字是com.zsd.dao而不是一层层的文件夹关系。最后改成正确的文件夹就可以了。
PS:resource文件夹建目录目前idea只能一层层的建。

2. 类名称写错

Mybatis:Type interface cn.itsun.dao.UserDao is not known to the MapperRegistry
Mybatis:Type interface cn.itsun.dao.UserDao is not known to the MapperRegistry

3. 没有在mybatis主配置的xml中填写需要映射的表的xml路径

Mybatis:Type interface cn.itsun.dao.UserDao is not known to the MapperRegistry