package com.farman.javaweb.controller; import com.farman.javaweb.entity.User; import com.farman.javaweb.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; @RestController public class Controller { @Autowired private UserService userService; @GetMapping("/list") public List<User> list(){ return userService.list(); } }运行上述代码'list(com.baomidou.mybatisplus.core.conditions.Wrapper<com.farman.javaweb.entity.User>)' in 'com.baomidou.mybatisplus.extension.service.IService' cannot be applied to '()'这个报错怎么解决
时间: 2023-12-29 19:02:50 浏览: 457
这个错误提示是因为在调用 `userService.list()` 方法时没有传入 `Wrapper` 参数,而 `IService` 接口中的 `list` 方法需要传入 `Wrapper` 参数。要解决这个问题,需要在 `userService.list()` 方法中传入一个 `Wrapper` 参数。具体的方法取决于你想要实现的查询条件,可以使用 `QueryWrapper` 或 `LambdaQueryWrapper` 等来构建查询条件。例如,如果你要查询所有 `User` 记录,可以这样修改代码:
```java
@GetMapping("/list")
public List<User> list(){
return userService.list(new QueryWrapper<>());
}
```
这样就可以成功调用 `userService.list()` 方法并返回 `List<User>` 类型的数据了。
阅读全文
相关推荐








