Performance: @Configuration and @Bean
MEDIUM IMPACT
This affects application startup time and memory usage by controlling how beans are created and managed in Spring's container.
@Configuration public class AppConfig { @Bean public MyService myService() { return new MyService(); } }
@Component @Scope("prototype") public class MyService { // service logic } // Multiple instances created if prototype scope or no singleton management
| Pattern | Bean Instances | Startup Time | Memory Usage | Verdict |
|---|---|---|---|---|
| @Component with prototype scope | Multiple instances possible | Higher due to redundant creation | Higher due to duplicates | [X] Bad |
| @Configuration with @Bean | Single instance per bean | Lower due to controlled creation | Lower due to reuse | [OK] Good |