Performance: @Component annotation
MEDIUM IMPACT
This affects application startup time and memory usage by controlling bean creation and dependency injection.
@Component
@Lazy
public class HeavyService {
public HeavyService() {
// expensive initialization
}
}@Component
public class HeavyService {
public HeavyService() {
// expensive initialization
}
}| Pattern | Bean Creation | Startup Delay | Memory Usage | Verdict |
|---|---|---|---|---|
| Eager @Component | Creates all beans at startup | High delay if many heavy beans | High memory usage | [X] Bad |
| @Component with @Lazy | Creates beans on demand | Minimal startup delay | Lower memory usage initially | [OK] Good |