Invalid bound statement (not found): com.heima.mapper.EmpMapper.selectByExample] with root cause

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 类的目录保持一致。
Invalid bound statement (not found): com.heima.mapper.EmpMapper.selectByExample] with root cause

2、必须告诉springboot到哪里加载 mapper.xml
在 application.properties文件中配置
mybatis.mapper-locations: classpath:com/heima/mapper/*.xml
Invalid bound statement (not found): com.heima.mapper.EmpMapper.selectByExample] with root cause

 

另外如果出现无法加载mapper类的时候,应该是启动类上没有添加
@MapperScan("com.heima.mapper")