idea springboot mybatis的xml配置时,发现无法找到接口的方法
报错 Invalid bound statement (not found)
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.hai.demo.mapper.CategoryMapper.findAll
at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:214) ~[mybatis-3.4.0.jar:3.4.0]
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:48) ~[mybatis-3.4.0.jar:3.4.0]
at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:59) ~[mybatis-3.4.0.jar:3.4.0]
..................................省略
配置和代码都检查过没问题,估计就是idea没有扫描源码目录下的xml
解决办法1:
pom.xml 的 build节点添加一下内容:
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
解决办法2:
把xml配置文件移到resources目录下,application.properties的配置为
mybatis.mapper-locations=classpath:/*.xml
参考:链接