問題描述
事情是這樣的,博主在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
不相似即可