Component scanning and stereotypes
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
say how beans are found and which stereotype to use.
Planned topics
@SpringBootApplicationincludes component scanning of its own package and sub-packages.- Stereotypes:
@Componentgeneric,@Servicebusiness logic,@Repositorydata access,@Controller/@RestControllerweb. - They all create beans; the names add meaning and some extra behavior (
@Repositorytranslates database exceptions). - A class outside the scanned packages is not found.
Draft outline details
Demonstration
com.shop.api.ShopApiApplication scans com.shop.api.**; a class in com.shop.other is missed.
Check your understanding
Where must the main class live?
Show answer
In the top package above all your code.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.