Best practice is to use @Resource instead of @Autowired because :
1. @Resource is defined in javax (JEE) while @Autowired is part of Spring APIs.
So, preferred to use Framework independent annotation which will not change,
when framework needs to be changed.
2. @Resource can be used in place of 2 annotations : @Qualifier and @Autowired
@Qualifier("arc")
@Autowired
private Shape arc1;
SAME AS :
@Resource("name=arc")
private Shape arc1;
No comments:
Post a Comment
Note: only a member of this blog may post a comment.