Performance: @Component, @Service, @Repository, @Controller
MEDIUM IMPACT
These annotations affect application startup time and memory usage by controlling bean creation and scanning.
@Service public class UserService { ... } @Repository public class UserRepository { ... } @Controller public class UserController { ... }
@Component public class UserService { ... } @Component public class UserRepository { ... } @Component public class UserController { ... }
| Pattern | Bean Scanning | Startup Time | Memory Usage | Verdict |
|---|---|---|---|---|
| @Component everywhere | High - scans all classes as generic beans | Slower due to extra scanning | Higher due to many beans | [X] Bad |
| @Service, @Repository, @Controller used | Optimized - scans with layer context | Faster startup | Lower memory footprint | [OK] Good |