Component scanning
Component scanning is a Spring mechanism that searches configured packages or classpath locations for eligible components and registers them as beans in the application context.
Spring in Action, Sixth Edition
A Spring technique that discovers eligible application components on the classpath and registers them as beans in the application context.
- How it is used
- Reduces explicit bean configuration by discovering annotated application components.
- How deep it goes
- Explains how scanning is enabled and discovers an annotated controller, without detailing scan boundaries.
- Examples
- Uses a Spring Boot bootstrap class and a home-page controller annotated with @Controller.
- What you can do after
- Apply component scanning with Spring Boot by enabling it through @SpringBootApplication and annotating eligible classes.
Read how Spring in Action, Sixth Edition explains component scanning →
Clean Applications with Hexagonal Architecture
A Spring mechanism that scans specified packages for eligible classes and registers them as application-context beans.
- How it is used
- Discovers architectural components in the assembly layer and lets Spring wire handlers to implementations of their declared interfaces.
- How deep it goes
- Configures package scope and annotation filters, distinguishes runtime resolution from declared dependencies, and leaves boundary enforcement to architecture tests.
- Examples
- Discovers @ApplicationService handlers and @Adapter persistence or notification components under a configured base package.
- What you can do after
- Configure Spring to discover stereotype-marked beans and resolve implementations for constructor-declared interfaces.
Read how Clean Applications with Hexagonal Architecture explains component scanning →
Also covered in
- Testing Spring Boot ApplicationsIn early access (MEAP)
Related concepts
- Spring beanproduces · A Spring bean is an object instantiated, configured, and managed by the Spring container.
- @SpringBootApplicationused by · @SpringBootApplication is a Spring Boot annotation that combines application configuration, auto-configuration, and component scanning.
- restcontroller annotationused by · @RestController is a Spring annotation that marks a class as a web controller whose handler return values are written directly to HTTP response bodies.
- stereotype annotationuses · A stereotype annotation marks a program element as belonging to a particular architectural or semantic role.
- controllerconfigured by · A controller is a software component that receives input or requests and coordinates other components or operations to produce a response or change application state.
- component decoratoruses · A component decorator or annotation attaches metadata to a class to identify or configure it as a component managed by a software framework.
Questions about component scanning
What is component scanning?
Component scanning is a Spring mechanism that searches configured packages or classpath locations for eligible components and registers them as beans in the application context.
Which Manning books explain component scanning?
Spring in Action, Sixth Edition and Clean Applications with Hexagonal Architecture.
What should I know before learning component scanning?
Manning books that teach component scanning usually introduce Java first.
What is component scanning also called?
Component scanning is also called @ComponentScan.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

