一、包結構
mapper所在的包結構:
二、問題描述
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) :
com.dapeng.flow.repository.mapper.RoleUserMapper.listUserId
經檢查,RoleUserMapper.java中listUserId與RoleUserMapper.xml的對應id一致,xml所在namespace也沒錯,xml返回類型也沒有錯。經過一邊耗時的排查,發現是mapper.xml所在位置在非resource下造成的。
三、解決方案
在項目所在的pom.xml中配置mapper所在的包掃描:
<resources>
<!--mapper.xml如果沒有放置在resource下,需要進行如下配置,否則會出現如下問題:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
-->
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>