1.使用mybatisplus通用mapper时通过service层的接口调用方法时出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example.test.service.StudentService.list错误
即
@Autowired
StudentService studentService;
方法调用
studentService.list(null);出现上述错误
2.但通过service层实现类调用方法时正常执行
即
@Autowired
StudentServiceImpl studentServiceImpl;
方法调用
studentServiceImpl.list();正常执行
3.原因是启动类上使用了@MapperScan注解,其范围太大,导致service接口也被包装了,调试时可以看到studentService接口的值为
com.baomidou.mybatisplus.core.override.MybatisMapperProxy@3d7dfa0e
正常的值应该为
com.example.test.service.impl.StudentServiceImpl@3a51e4cf
4.解决办法:
缩小@MapperScan注解的扫描范围为具体的mapper路径,类似于@MapperScan(“com.xxx.test.mapper”)