What is auto configuration in Spring Boot?
Auto configuration is the Spring Boot feature that automatically sets up beans and settings based on the libraries on your classpath. For example, if it finds a database driver, it configures a data source for you. It is triggered by the EnableAutoConfiguration annotation, which the SpringBootApplication annotation includes, and you can always override its defaults.
How it decides
Spring Boot looks at what is on the classpath and applies matching configuration using conditional checks. If a class is present and you have not defined your own bean, it provides a sensible default one.
@SpringBootApplication // includes @EnableAutoConfiguration
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
You are never locked in. If you define your own bean or set a property, your choice wins over the auto configured default.
Mention that auto configuration is conditional and overridable. Saying it backs off when you provide your own configuration shows you understand it assists you rather than taking control away.
Common follow up questions
Related interview questions
Want the full Spring Boot guide?
Read every Spring Boot concept with notes, diagrams, and code in one place. Track your progress as you go.
Open the Spring Boot guide All Spring Boot questions