Код: Выделить всё
@Component
public class StudentService {
private final StudentDao studentDao;
@Autowired
public StudentService(@Qualifier("fakeDao") StudentDao studentDao) {
this.studentDao = studentDao;
}
//for the sake of relevance not putting other methods here, but I have all CRUD methods defined here
//in the class.
}
Код: Выделить всё
@RestController
@RequestMapping("api/v1/students")
public class StudentResource {
@Autowired
private final StudentService studentService;
public StudentResource(StudentService studentService) {
this.studentService = studentService;
}
}
Код: Выделить всё
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
[2m2020-10-05 22:06:19.236[0;39m [31mERROR[0;39m [35m7228[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.b.d.LoggingFailureAnalysisReporter [0;39m [2m:[0;39m
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.centene.demo.resource.StudentResource required a bean of type 'org.centene.demo.service.StudentService' that could not be found.
Action:
Consider defining a bean of type 'org.centene.demo.service.StudentService' in your configuration.
JAva 1.8
Spring boot 2.3.4
Подробнее здесь: https://stackoverflow.com/questions/642 ... ot-applica