1. 程式人生 > >解決org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): XXX

解決org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): XXX

錯誤圖如下:

我找到兩個原因都可以構成這種錯誤:

原因一:mapper介面的方法名和xml檔案裡對應的語句的id名不同,id和方法改為一致的即可解決。

原因二:先看下面的截圖

這是spring配置檔案中的一段:

這是資原始檔夾下mapper檔案下的xml檔案:

在檢查了很久xml和介面沒問題後,我終於看到了這個坑爹的錯誤,我在spring配置檔案中掃描的是.xml結尾的,而這裡只有UserMapper.xml被掃描到!!!所以其他另個xml中的方法一旦被呼叫也會報上面的錯誤。