欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Mapped Statements collection does not contain value for [namespace]

程序员文章站 2022-07-15 12:13:53
...

mybatis 入门练习项目报错:

### Error updating database.  Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for c***********ent
### Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for c***********ent
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26)

    at ………………

原因在于session执行的映射文件名错误,与映射文件中<mapper namespace="***********">不一样

// Test.java
SqlSession session = factory.openSession();
session.insert("com.lee.dao.IStudentMapper.saveStudent"); // 映射文件路径
<!-- StuMapper.xml -->
<mapper namespace="com.lee.dao.IStudentMapper">