【发布时间】:2021-01-14 23:56:18
【问题描述】:
我正在创建一个 Springboot 项目,其中我有两个服务接口,我将它们注入到我的控制器中
学生服务
public interface StudentService {
void addStudent(Student student);
//other functions
}
教师服务
public interface TeacherService {
void addStudent(Teacher teacher);
//other functions
}
当我将 @Autowired 用于 StudentService 时,它工作正常,但当我在 Controller 中将 @Autowired 用于 TeacherService 时却出现错误。我尝试了很多,但没有找到错误的原因。
我的控制器
@Controller
public class StudentController {
@Autowired
StudenService studenService;
....
....
}
@Controller
public class TeacherController {
@Autowired
TeacherService teacherService;
....
....
}
【问题讨论】:
-
你有没有被@Service 惹恼的两个接口的实现?
-
你得到什么样的错误?
-
StudentService 和 StudenService 之间有错别字
标签: java spring spring-boot