解决org.apache.ibatis.binding.BindingException: Type interface XXX is not known to the MapperRegistry.

org.apache.ibatis.binding.BindingException: Type interface com.byh.mapper.OrderMapper 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:675)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.getMapper(DefaultSqlSession.java:250)
    at Demo2.bef(Demo2.java:37)
    ......

 

在做mybatis的例子中遇到这个错误。

检查了好一会后,发现错误是:

1、xml文件的namespace的值对应的mapper接口写错了。

2、xml文件没有被添加到mybatis的配置文件中扫描。

你可能感兴趣的:(mybatis,bug)