一:问题
自定的sql在运行时发生错误,报“org.apache.ibatis.binding.BindingException”,搜了很多方法,有说namespace路径不对应的,有说方法名与id不对应的,也有说返回值类型有错,这些我都一一检查了,没有问题。
2022-09-30 15:09:26.244[exec-1]ERROR:Exception class: org.apache.ibatis.binding.BindingException
2022-09-30 15:09:26.244[exec-1]ERROR:ex.getMessage():Invalid bound statement (not found): com.agrij.asset.mybatisEdition.tableModule.mapper.AssetAlltablesMapper.getprinttables
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
2022-09-30 15:09:26.272[exec-1] WARN:Resolved [org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.agrij.asset.mybatisEdition.tableModule.mapper.AssetAlltablesMapper.getprinttables]
2022-09-30 15:09:26.285[exec-2] WARN:call:/favicon.ico
这是我启动类上的扫描配置:
mapper上的配置也都存在
id与方法名也都相同
并且,在我使用mybatis-plus自带的方法时,没有问题。
二:解决方法:
在pom中添加一段代码
</build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>`
</resources>
</build>
原因是在于xml文件不能放在java文件夹中,idea默认不会编译源码文件中的xml文件