springboot 整合 mybatis的時候報錯:
nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.heima.mapper.EmpMapper.selectByExample] with root cause
分析:沒有掃描到 mapper.xml
1、mapper.xml文件一般配置在 resources下,目錄與java mapper 類的目錄保持一致。
2、必須告訴springboot到哪裏加載 mapper.xml
在 application.properties文件中配置
mybatis.mapper-locations: classpath:com/heima/mapper/*.xml
另外如果出現無法加載mapper類的時候,應該是啓動類上沒有添加
@MapperScan("com.heima.mapper")