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没有与实现接口相对应。

Mapped Statements collection does not contain value for

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

Mapped Statements collection does not contain value for

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

Mapped Statements collection does not contain value for

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

<dependency>
   <groupId>org.mybatis.spring.boot</groupId>
     <artifactId>mybatis-spring-boot-starter</artifactId>
     <version>2.2.1</version>
 </dependency>

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

<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.3.1</version>
</dependency>
上一篇:docker网络(三)--macvlan


下一篇:Docker 网络模型之 macvlan 详解,图解,实验完整