版本:3.1.0
代码如下:
public interface UserService extends IService {
boolean modify(User entity);
}
public class UserServiceImpl extends ServiceImpl implements UserService {
@Override
public boolean modify(User entity) {
return new LambdaUpdateChainWrapper<>(this.baseMapper)
.eq(User::getStatus, entity.getStatus())
.eq(User::getType, entity.getType())
.update(entity);
}
}
直接使用UserMapper可以调用成功,但是使用UserService.modify就报错
2020-02-18 13:28:39.652 [XNIO-2 task-1] ERROR -
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.user.service.UserService.modify
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod$SqlCommand.(MybatisMapperMethod.java:242)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.(MybatisMapperMethod.java:54)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.lambda$cachedMapperMethod$0(MybatisMapperProxy.java:65)
at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.cachedMapperMethod(MybatisMapperProxy.java:65)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:60)
at com.sun.proxy.$Proxy115.modify(Unknown Source)
at com.user.controller.UserController.modify(UserController.java:41)
......
Comment From: yuandaqianchengli
@Autowired
protected UserService UserService;
@Autowired
protected UserServiceImpl UserService;
注入接口报错,注入实现类不报错,难道是找不到实现类,求大神解答???
Comment From: yuandaqianchengli
已解决。
有点坑爹啊,居然是@MapperScan配置有问题,需要精确到包名,比如:
@MapperScan("com.user.mapper")