Mybatis遇到org.apache.ibatis.binding.BindingException:异常的解决方案

如果遇到org.apache.ibatis.binding.BindingException: Type interface com.abin.Dao.UserMapper is not known to the MapperRegistry.错误

证明核心配置文件中没有注册mappers

需要在核心配置文件中注册每个mapper

<!--    每一个***Mapper.xml等都需要在Mybatis核心配置文件中注册!!!-->
    <mappers>
        <mapper resource="com/abin/Dao/UserMapper.xml"/>
    </mappers>

也可以直接扫描一个包中的所有mapper.xml文件

<!-- 将包内的映射器接口实现全部注册为映射器 -->
<mappers>
  <package name="com.abin.dao"/>
</mappers>

版权声明:本文为qq_26185495原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。