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(2)如果如果pom.xml使用的是:mybatis-plus-boot-starter 则yml中应该配置 mybatis-plus:mapper-locations: classpath:mapper/*.xmlorg.mybatis.spring.boot mybatis-spring-boot-starter2.2.1
com.baomidou mybatis-plus-boot-starter3.3.1
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)