What\'s the difference between @Inject
and @Resource
and @Autowired
annotations?
When should we use each of them?
|------------|---------------|---------------|---------------|-----------------------|
| | Setter/Field | Constructor | Applicable to | Matching order |
| | injection | injection | type | |
|------------|---------------|---------------|---------------|-----------------------|
| @Autowired | X | X | | Type, Qualifier, Name |
|------------|---------------|---------------|---------------|-----------------------|
| @Inject | X | X | | Type, Qualifier, Name |
|------------|---------------|---------------|---------------|-----------------------|
| @Resource | X | | X | Name, Type, Qualifier |
|------------|---------------|---------------|---------------|-----------------------|
So in Spring dependency injection @Inject
and @Autowired
have exactly the same behaviour.