使用idea测试mabtis实例时出现 java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for...
原因是idea找不到xxxMapper.xml文件,target中没有对应的mapper文件夹
在pom.xml中加入
<build> <!--扫描到xml文件--> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> </resource> </resources> </build>
执行之后
注意:IDEA的扫描机制,src/main/java 中的xml文件不会被扫描到
2019-02-02 19:12:12
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
发现编译后的mapper文件中有mapper的class文件,但是没有mapper的xml文件
在pom.xml中加入扫描mapper的xml文件的配置即可解决。
原因是由于idea没有扫描到src/main/java 中的xml文件。