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

  • 相关阅读:
    记Git报错-Everything up-to-date
    开发相关的绝赞网站和框架
    记Git报错-refusing to merge unrelated histories
    Nodejs和npm入门使用
    【转】什么是JavaScript
    CSS学习摘要-定位实例
    golang 文件服务器
    golang postgresql CRUD
    golang sqlite3 CRUD
    psql: 致命错误: 对用户"user1"的对等认证失败
  • 原文地址:https://www.cnblogs.com/tongongV/p/14188678.html
Copyright © 2011-2022 走看看