错误截图
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
错误原因
对于IDEA系列编辑器,XML 文件是不能放在 java 文件夹中的,IDEA 默认不会编译源码文件夹中的 XML 文件。
解决方法
方法一. 将文件转到resource文件夹下
# 这里mapper是resource下的文件夹,xml在此文件夹下
mapper-locations: classpath*:mapper/*.xml
方法二. 不将文件移动到resource,在pom.xml下加入以下配置使得src/main/java下的静态文件能被查找
# 此时路径配置如下
# mapper-locations: classpath:com/bbs/mapper/xml/*.xml
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>