Hard20 minSpring Boot Fundamentals
UpdatedAug 5, 2026
Edit

Spring Boot Auto-Configuration

Question Variations

  • "How does Spring Boot decide to configure a bean?"
  • "How do you override an auto-configured component?"
  • "What does a starter dependency provide?"

Why This Is Asked

Interviewers use auto-configuration to assess whether you understand Spring Boot defaults, conditions, and safe customization.

Key Concepts

  • Auto-configuration creates beans conditionally from the classpath, properties, and existing beans.
  • Starters provide coherent dependency sets.
  • Application beans can back off or override defaults deliberately.
  • The condition evaluation report helps diagnose configuration.

Question Variations

  • “How does Spring Boot decide to configure a bean?”
  • “How do you override an auto-configured component?”
  • “What does a starter dependency provide?”

Answers by Technology

+ Add Variant
Spring BootImprove this answer ✏️

Expected Answer (Spring Boot 4.1.0 / Java 17+)

Spring Boot auto-configuration creates infrastructure beans when conditions match the classpath, configuration properties, and beans already defined by the application. Starters bring compatible dependencies, then Boot applies sensible defaults such as an embedded web server or data source. Auto-configuration generally backs off when you define your own bean of the relevant type, letting applications customize a default without replacing every piece of configuration.

Why It Matters

Understanding conditions prevents accidental duplicate beans and makes startup failures diagnosable instead of mysterious.

Code Example

@SpringBootApplication
public class Application {
  @Bean
  Clock clock() { return Clock.systemUTC(); }
  public static void main(String[] args) { SpringApplication.run(Application.class, args); }
}

Common Mistakes

  • Treating auto-configuration as magic: Conditions and application beans determine the result.
  • Overriding a bean without understanding consumers: Incompatible replacements can break dependent configuration.

Follow-up Questions

  • How can you inspect auto-configuration conditions? (Answer: Enable Spring Boot’s condition evaluation report.)
  • What does a starter provide? (Answer: A curated dependency set and compatible defaults.)