Why this matters
- Knowing what each meta-annotation does lets you troubleshoot startup issues — like beans not being found or unwanted auto-config loading.
- Boot-specific annotations (
@ConditionalOn*,@ConfigurationProperties) are the vocabulary for custom starters and library integration. - Interview questions often ask what
@SpringBootApplicationactually contains.
@SpringBootApplication composition
L1 · FresherCombines @Configuration, @EnableAutoConfiguration, and @ComponentScan. That trio is why BookStore starts with one annotation on the main class.
@EnableAutoConfiguration
L2 · IntermediateImports auto-config classes from META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports. Your @Bean methods override defaults via @ConditionalOnMissingBean.
Excluding auto-config
L3 · Advanced@SpringBootApplication(exclude = DataSourceAutoConfiguration.class) disables specific configs — use when swapping JPA for JDBC or running slice tests without a database.
scanBasePackages tuning
L4 · ExpertNarrow scan packages in large monorepos to avoid picking up unrelated @Component classes. Pair with @Import for modular configuration without broad scans.
Decomposing @SpringBootApplication
// learn:fragment
@SpringBootApplication
public class BookStoreApplication { ... }
Expands to three annotations:
@SpringBootConfiguration // alias for @Configuration
@EnableAutoConfiguration // load auto-config classes from META-INF
@ComponentScan // scan current package and below
Each serves a distinct purpose in the startup sequence.
Core bootstrap annotations
@SpringBootConfiguration— Marks the class as a source of@Beandefinitions; typically only on the main class.@EnableAutoConfiguration— ImportsAutoConfigurationImportSelectorwhich loads conditional config fromMETA-INF/spring/.@ComponentScan— Discovers@Component,@Service,@Repository,@Controllerin the package tree.
The rest of this guide is part of Pro
Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.
Still to come · 7 sections
- Customising the scan root
- @Configuration and @Bean
- Conditional annotations preview
- @ConfigurationProperties
- Web layer annotations
- Transaction and caching annotations
- Testing annotations
Test yourself
Answer these before moving on — recall is what makes it stick.