【MyBatis】:Type interface com.atguigu.mybatis.mapper.UserMapper is

  • Post author:
  • Post category:其他


如果你学过尚硅谷SSM视频可能出现的一个问题

昨天调代码时候出现的一个bug,希望大家能够注意下

org.apache.ibatis.binding.BindingException: Type interface com.atguigu.mybatis.mapper.UserMapper is not known to the MapperRegistry.

错误发生在这一行

你只需要将映射文件中的package name改为 mapper resource即可,因为你学到这里的时候,可能还没有学过包引入映射文件,这是通过文件引入

循序渐进,在前期是通过mapper resource引入配置文件,后面可以用包名直接引入,更简洁

<!--引入映射文件-->
    <mappers>
        <package name="mappers/UserMapper.xml"/>
    </mappers>

修改核心配置文件mybatis-config.xml成功解决



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