Loading
Spring Configuration-interview

Q1. What is Spring Configuration?

Spring Configuration tells the IoC container which beans to create, how to inject dependencies, and how to manage their lifecycle.
Without configuration, Spring does not know what objects your application needs.


Q2. Why is Spring Configuration important?

Because it controls IoC (Inversion of Control) and DI (Dependency Injection).

It decides:

  • Which classes become beans
  • How dependencies are wired
  • How beans are created and destroyed
  • Configuration is the brain of a Spring application.


Q3. What are the three Spring configuration approaches?

  • XML-Based Configuration
  • Java-Based Configuration
  • Annotation-Based Configuration

All three achieve the same goal but differ in style and modern usage.


Q4. What is @Configuration used for?

@Configuration marks a class as a Java configuration class, meaning it contains @Bean methods that define Spring beans.


Q5. Difference between @Bean and @Component?

  • @Bean → used inside @Configuration classes to create beans manually
  • @Component → placed on classes to auto-detect beans using component scanning

Both create beans but in different styles.