component scanning
Spring searching the application's packages at startup for classes marked with annotations such as @Service and registering them as beans.
In more detail
@SpringBootApplication turns on scanning from its own package downward, so keep the application class at the root of your packages. Classes outside the scanned packages are silently ignored, a common cause of a missing bean at startup.
Related terms
- @SpringBootApplication — The annotation on a Spring Boot main class that switches on component scanning, auto-configuration and configuration declarations in one go.
- @Service — A Spring annotation that marks a class as a service bean so component scanning discovers and creates it.
- Spring bean — An object that the Spring container creates, configures and manages, and can inject into other beans.
Taught in
- Spring Boot Auto Configuration — Modern Java: Virtual Threads & High-Throughput Services