MyBatis—— org.apache.ibatis.binding.BindingException: Type interface com.web.mybatis.i.PersonMapper is not known to the MapperRegistry.

报错信息:

Exception in thread "main" org.apache.ibatis.binding.BindingException: Type interface com.web.mybatis.i.PersonMapper 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:750)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.getMapper(DefaultSqlSession.java:292)
    at com.web.mybatis.test.Test.oneToOneTest(Test.java:14)
    at com.web.mybatis.test.Test.main(Test.java:24)

原因:使用MyBatis框架访问数据库时,与Mapper文件对应的接口和mapper文件的文件路径不相同

将mapper文件和接口文件放到同一包下

 

posted @ 2019-04-08 15:36  !O0O!  阅读(1381)  评论(0编辑  收藏  举报