File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes Use of Qualifiers in Autowiring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Use of Qualifiers in Autowiring" Watch "Use of Qualifiers in Autowiring" New topic

Use of Qualifiers in Autowiring

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9999


Why would I use a Qualifier attribute when I autowire my beans?

SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

@Autowired is fundamentally about type-driven injection. If you have more than one beans with that have the same type, you need to use @Qualifier to tell which bean that you're referring to.

I prefer to use @Resource for such case, though.

SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
I agree. Here's the link:
subject: Use of Qualifiers in Autowiring
It's not a secret anymore!