InterviewVault
Welcome back, Sujit Kumar Mishra
Admin
SK Mishra
SKM
Revision Mode
Document technical questions and best-practice answers.
@Qualifier Annotation
- What is the purpose of the @Qualifier annotation in Spring?
The @Qualifier annotation in Spring is used to specify which bean should be injected when there are multiple beans of the same type. It helps Spring know exactly which one you want.
In simple words:
When you have more than one bean of the same kind, use @Qualifier to tell Spring which one to use.
Example:
If you have two beans called "apple" and "orange", and you want Spring to use "apple", you write:
@Autowired
@Qualifier("apple")
private Fruit fruit;
This way, Spring will inject the "apple" bean into your code.
Ready for commit