`在使用Mybatis的selectList()方法时候出现了报错 @Slf4j @RestController @RequestMapping("/emps") public class EmpController { @Autowired private EmpService empService; /** * 查询员工
- @return
/
@GetMapping("/list")
public Result list() {
log.info("查询员工列表");
// 调用service层方法查询员工列表
List empsList = empService.selectList();
return Result.success(empsList);
}
}
/* * 员工 /
public interface EmpService extends IService {
/*
- 查询全部
- @return */ List selectList(); }
- 员工 / @Service public class EmpServiceImpl extends ServiceImpl<EmpMapper, Emp> implements EmpService { /*
- 查询全部
- @return
*/
@Override public List selectList() {
List empsList = selectList();
return empsList;
}
}
开始EmpServiceImpl的代码里面自动注入的是
@Autowired private EmpService empService; 在用APIfox运行的时候控制台直接报依赖循环问题,*************************** APPLICATION FAILED TO START *************************** Description: The dependencies of some of the beans in the application context form a cycle: empController (field private com.itheima.service.EmpService com.itheima.controller.EmpController.empService) ┌─────┐ | empServiceImpl (field private com.itheima.service.EmpService com.itheima.service.impl.EmpServiceImpl.empService) └─────┘"后面我直接把@Autowired private EmpService empService;给删除了.后面有给我报了"No static resource list."错误,后面发现是我自动注入错了,改成"@Autowired private EmpMapper empMapper;",再搭配上MybatisPlus的方法,就能查询出员工的全部信息