Mybatis詭異的org.apache.ibatis.binding.BindingException(曾經的坑)

問題描述

事情是這樣的,博主在Spring boot環境下使用 Mybatis
卻遇到了意料之外的 org.apache.ibatis.binding.BindingException

還原問題

配置的mapper.xml 目錄路徑

classpath:/mapper/*.xml

項目目錄結構

測試下的org.xavier.test也有 叫 mapper的 子包

確保了 interface 已和 Mapper.xml 正確對應 、Spring boot 入口 Application.java 有正確掃描 Mapper Bean

問題實質

框架去 test 包下找對應的mapper.xml 了

解決方案

重新命名測試包 包名,讓測試包包名 與

classpath:/mapper/*.xml

不相似即可

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章