mybaits-plus Invalid bound statement (not found): com.lyl.mapper.UserMapper.deleteById
时间: 2023-11-26 09:47:19 浏览: 51
根据提供的引用内容,出现"Invalid bound statement (not found)"的原因可能是MyBatis-Plus无法找到对应的Mapper方法。解决这个问题的方法是检查Mapper接口中是否存在名为"deleteById"的方法,并且该方法的参数类型与传入的参数类型一致。如果Mapper接口中不存在该方法,则需要手动添加该方法。
以下是一个示例代码,演示如何使用MyBatis-Plus的deleteById方法删除指定id的记录:
```java
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
@Override
public boolean deleteUserById(Long id) {
int result = baseMapper.deleteById(id);
return result > 0;
}
}
```
在上面的示例代码中,我们使用了MyBatis-Plus提供的BaseMapper接口中的deleteById方法来删除指定id的记录。在Service层中,我们可以直接调用baseMapper的deleteById方法来实现删除操作。