1. 程式人生 > >解決org.apache.ibatis.binding.BindingException: Type interface XXX is not known to the MapperRegistry.

解決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的配置檔案中掃描。