Interview questions
Question 41 of 254
FreeWhat is @Configuration and how does it differ from a plain class with @Bean methods?
Spring Configuration
@Configuration marks a class as a source of bean definitions, and — crucially — Spring generates a CGLIB subclass of it at runtime so that calling one @Bean method from another within the same class returns the same singleton instance rather than creating a new object each time. Without @Configuration (e.g., using @Component with @Bean methods instead), that inter-method call semantics is lost and each call creates a fresh instance, silently breaking singleton semantics.
Intermediate5 min

