Bootstrapmedium0-2 years
What does @SpringBootApplication actually do?
It's a meta-annotation that composes three: @SpringBootConfiguration (a specialised @Configuration, so the class itself can declare @Bean methods), @EnableAutoConfiguration (turns on the conditional auto-configuration machinery), and @ComponentScan (scans the package the annotated class lives in, and everything below it, for @Component/@Service/@Repository/@Controller). That's also why the convention is to put the main class in the application's root package — anything outside it is invisible to component scanning by default.
PreviousHow does Spring Boot auto-configuration decide what to configure, and how do you find out why a bean is missing?Next What is a Spring Boot starter, and how does spring-boot-dependencies keep all those library versions compatible?