zoukankan      html  css  js  c++  java
  • @MapperScan 注解和 mybatis.mapper-locations 配置两者缺一不可

    @MapperScan 注解和 mybatis.mapper-locations 配置两者缺一不可

    @MapperScan(basePackages="xxx.xxx.xxx") 这个注解是用户扫描 mapper 接口的,也就是dao类;
    mybatis.mapper-locations 配置是用于扫描 mapper.xml 的;
    两者用途不同,故缺一不可。

    如下,

    mybatis:
    mapper-locations: classpath:mapping/*Mapping.xml

    @MapperScan("com.example.demo.mapper")

    如果遇到类似下面的错误,通常就是 mapper.xml 文件找不到,请先检查以上两个配置是否正常。

    例1:

    Caused by: org.apache.ibatis.builder.IncompleteElementException: Could not find result map xxx.xxx.xxx.BaseResultMap

    例2:

    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dynamicSecurityMetadataSource': Invocation of init method failed; nested exception is org.apache.ibatis.builder.IncompleteElementException: Could not find result map xxx.xxx.xxx.BaseResultMap

    例3:

    Caused by: java.lang.IllegalArgumentException: Result Maps collection does not contain value for xxx.xxx.xxx.BaseResultMap

    例4:

    Could not find result map xxx.xxx.xxx.BaseResultMap

    例5:

    org.apache.ibatis.binding.BindingException: Invalid bound statement (not fou

    原文链接和参考资料:

    解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题_写代码的蜗牛-CSDN博客  https://blog.csdn.net/sundacheng1989/article/details/81630370

    @MapperScan 注解和 mybatis.mapper-locations 配置两者缺一不可 – CroWall  https://crowall.com/archives/mybatis-mapper-scan-and-locations.html

  • 相关阅读:
    luogu P1455 搭配购买
    浅谈筛素数
    luogu P1205 方块转换
    luogu P2241 统计方形
    luogu P1866 编号
    luogu P1042 乒乓球
    4.7清明考试(完蛋)
    LINUX 启动图形界面和查看运行级别
    密钥登录LINUX步骤
    服务命令只支持基本的LSB操作(启动、停止、重新启动、尝试重启、重新加载、强制重新加载、状态)。对于其他操作,请尝试使用systemctl。
  • 原文地址:https://www.cnblogs.com/tongongV/p/14188678.html
Copyright © 2011-2022 走看看