即在mybatis中dao接口與mapper配置文件在做映射綁定的時候出現問題。
原因:接口與xml找不到,或者是找到了卻匹配不到。有以下原因,需要逐條核查:
1、接口名與Mybatis的映射文件名一定要不一樣;
2、XXXMapper.xml 文件 mapper 節點中 namespace 是否和 mapper 接口的所在包名一致;
3、XXXMapper.xml文件 mapper 節點下 id 是否在接口中有對應方法;
4、XXXMapper.xml文件 mapper 節點下所有 id,是否已全部包含了對應接口中的所有方法;
5、接口中返回值類型是List<XXX>,而select元素沒有正確配置 ResultMap 或者 resultType ;
6、XXXmapper.XML配置路徑:
如果在Resource下,則application.yml :mapper-locations: classpath:文件夾名/*.xml

如果在java下其他位置,則application.yml:
mapper-locations: classpath*:com/lsk/xxxxx/mapperXml/*.xml
注意 classpath后有“*”,並且包地址是“/”分割
另外,還需要在pom.xml增加build節點:
<build>
<resources>
<resource>
<filtering>true</filtering>
<directory>${basedir}/src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>${basedir}/src/main/java</directory>
<excludes>
<exclude>**/*.xml</exclude>
</excludes>
</resource>
</resources>
</build>
