栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Mapped Statements collection does not contain value for

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Mapped Statements collection does not contain value for

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.example.demo.dao.impl.DepartmentDaoImpl.getById
### Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.example.demo.dao.impl.DepartmentDaoImpl.getById

产生这种错误的原因一般有二点:

1.是mapper.xml文件的namespace没有与实现接口相对应。

2.在接口的实现方法中没有正确填写对应xml文件的namespace。

3.还有一个原因是 spring没有扫描到mapper.xml。这一般与mybatis的 mapper-locations 配置相关。

(1)如果pom.xml使用的是: mybatis-spring-boot-starter 则yml文件中应该配置 mybatis:mapper-locations: classpath:mapper/*.xml

   org.mybatis.spring.boot
     mybatis-spring-boot-starter
     2.2.1
 
(2)如果如果pom.xml使用的是:mybatis-plus-boot-starter 则yml中应该配置 mybatis-plus:mapper-locations: classpath:mapper/*.xml

    com.baomidou
    mybatis-plus-boot-starter
    3.3.1

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/692369.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号