Performance: @Autowired for dependency injection
MEDIUM IMPACT
@Autowired affects application startup time and memory usage by managing object creation and wiring dependencies automatically.
public class Service {
@Autowired
private Repository repo;
}public class Service {
private Repository repo = new Repository();
}| Pattern | Bean Creation | Dependency Resolution | Memory Usage | Verdict |
|---|---|---|---|---|
| Manual new operator | Multiple independent instances | No automatic resolution | Higher due to duplicates | [X] Bad |
| @Autowired field injection | Singleton beans reused | Automatic resolution at startup | Optimized by Spring container | [OK] Good |