1.

Differentiate between the @Autowired and the @Inject annotations.

Answer»
@Autowired@Inject
This annotation is part of the Spring framework.This annotation is part of Java CDI.
Has required attribute.Does not have the required attribute.
Singleton is the default scope for autowired beans.Prototype is the default scope of inject beans.
In case of ambiguity, then @Qualifier annotation is to be used.In case of ambiguity, then @NAMED qualifier needs to be used.
Since this annotation is provided by the Spring framework, in case you shift to another Dependency injection framework, there WOULD be a LOT of refactoring needed.Since this annotation is part of Java CDI, it is not framework dependent and hence LESS code refactoring when there are framework CHANGES.


Discussion

No Comment Found