From the course: Spring: Framework in Depth
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
The component scan
- [Instructor] If you have ever used Spring Boot, the auto-configuration is partially achieved through component scanning mixed with conditional configurations. In fact for many classes external configuration isn't needed as component scanning can solve the configuration for you. The root annotation that is used for component scanning is that component. This annotation indicates that the class should be loaded into the BeanFactory and configured using annotations and inspections of the class itself. Component is the root annotation, but there are several stereotypes of this annotation that can be used. Often you want to use these stereotypes like @Service so you can write your own aspects to add behavior to your classes based on type. We will go through an example of that later on. Component scanning scans the base package and that package's sub packages and loads configuration automatically for each bean it finds.…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.