Type interface XXXMapper is not known to the MapperRegistry.的解决办法。

最近一直用SpringMvc+Mybabis做项目,见同事一直报Type interface XXXMapper is not known to the MapperRegistry.这个错误,google了半天,网上的说法都是说Mapper xml中的namespace对应的实体类的路径不对,查看了半天一直找不到错误,debug了半天后来终于发现了问题,问题所在就是:我的项目依赖的有两个jar包,获取sqlSession的方式都是
InputStream inputStream = Resources.getResourceAsStream(config);

SqlSessionFactorysqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);

getResourceAsStream中是MapperConfig的文件名,依赖的两个jar包各自有一个MapperConfig.xml,该文件中引入的xxxxmapper.xml不同,导致调用的时候只加载了一个MapperConfig.xml中的mapper.xml,对应的mapper没有注册到mybatis的MapperRegistry中所以会一直报Type interface XXXMapper is not known to the MapperRegistry.特此收录一把,仅供参考。

转载前请指明本文地址:http://anonymman.iteye.com/blog/2138316

猜你喜欢

转载自anonymman.iteye.com/blog/2138316