What is @Qualifier used for in Spring?

Updated May 17, 2026

Short answer

@Qualifier resolves ambiguity when multiple beans of same type exist.

Deep explanation

When Spring finds multiple candidate beans, @Qualifier specifies which bean to inject by name, avoiding NoUniqueBeanDefinitionException.

Real-world example

Choosing between Stripe and PayPal payment services.

Common mistakes

  • Relying only on @Primary when multiple configurations exist.

Follow-up questions

  • What is @Primary?
  • Can @Qualifier be used with constructor injection?

More Spring interview questions

View all →