报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.msx.mapper.UserMapper.getUserInfo
原因:比较常见的就是
- namespace错误,导致无法自动绑定
- pom依赖没有加入
<dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.1.4</version> </dependency>
- mapper没有扫描到,在配置文件中或是启动类中加入扫描
mybatis: mapper-locations: classpath:(xml文件路径)/*.xml
或是加入@MapperScan("xml文件路径")
- mapper文件注解是否加全,@Mapper必须的,还有一个生成bean的注解
- mapper.xml里面的文件的id是否和接口mapper的方法名称一致
- xml文件名称(自己遇到,排查了大半天,少了.xml生成的文件也是xml文件),一定手动新增文件的时候就写上xml
如图上面这个,