Invalid bound statement (not found): com.example.dao.UserDao.login
时间: 2023-12-17 10:28:55 浏览: 223
这个错误通常是因为Mybatis无法找到对应的Mapper映射文件中的SQL语句所导致的。解决方法如下:
1. 确认Mapper映射文件中是否存在对应的SQL语句,以及SQL语句的id是否与代码中调用的一致。
2. 确认Mapper接口的包路径是否正确,以及是否在启动类上加上了@MapperScan注解,指定了Mapper接口所在的包路径。
3. 确认Mapper接口的方法名是否与Mapper映射文件中的id一致,且参数类型和个数是否匹配。
4. 如果以上方法都无法解决问题,可以尝试重启项目或者清除缓存重新编译。
下面是一个示例代码,假设我们有一个UserDao接口,其中有一个login方法,对应的Mapper映射文件为UserMapper.xml,其中id为userLogin:
```java
public interface UserDao {
User login(String username, String password);
}
```
```xml
<!-- UserMapper.xml -->
<mapper namespace="com.example.dao.UserDao">
<select id="userLogin" resultType="com.example.entity.User">
select * from user where username=#{username} and password=#{password}
</select>
</mapper>
```
如果在调用login方法时出现了Invalid bound statement (not found): com.example.dao.UserDao.login错误,可以按照上述方法进行排查和解决。
阅读全文
相关推荐

















