Use @Autowired and @Component from Service to Controller

preview_player
Показать описание
We want to connect our service class to our UI controller. We can use the @Autowired and @Component annotations, along with @SpringBootApplication, @ComponentScan, or component-scan, to make this happen. In this video, we do this in a hands-on example in Eclipse.

Рекомендации по теме
Комментарии
Автор

In SpecimenServiceStub at 5:32, we can view the code whereby a SpecimenDTO object is returned from the fetchById method (lines 22-28). When this Stub class is eventually replaced by the prod SpecimenService, how is this fetchById method replaced (since presumably we would no longer be hard-coding its output)? I assume that in the prod instance, SpecimenService would hit ISpecimenDAO and retrieve content from a database, but if for instance our unit tests relied upon the fake SpecimenDTO instantiated and returned in lines 22-28 of SpecimenServiceStub, wouldn't all the tests that previously used SpecimenServiceStub now break?

almiller