The metadata that tell Spring how to manage classes, methods, or fields. Let Spring to:
- Auto detect beans
- Manage dependencies
- Configure behavior at runtime
// replace manual XML configuration: code cleaner & maintainable.
@SpringBootApplication
- Mark the main config class of the app.
- Saves boilerplate
- Auto-configuration power
- Convention over configuration
@Configuration
- Marks the class as a source of bean definitions for the application context.
@EnableAutoConfiguration
- Tells Spring Boot to auto add beans based on classpath settings, other beans, and property settings
- Without this, need to config all @Bean manually.
- If have
spring-boot-starter-web on classpath: auto-configures Tomcat, DispatcherServlet, and Jackson JSON converter.
- How it work:
- Checks classpath (dependencies)
- Checks application.yml
- Applies
@Conditional rules
@ComponentScan