seniorSpring

What is Spring Boot auto-wired ambiguity resolution strategy?

Updated May 17, 2026

Short answer

Spring resolves multiple bean candidates using @Primary, @Qualifier, and bean name matching.

Deep explanation

When multiple beans of the same type exist, Spring first checks for a @Primary bean, then looks for @Qualifier annotations, and finally falls back to matching bean names. If ambiguity remains unresolved, Spring throws NoUniqueBeanDefinitionException. This mechanism ensures deterministic dependency resolution in complex applications.

Unlock with a Pro subscription to view this section.

View pricing

Real-world example

No real-world example available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Common mistakes

No common mistakes listed yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Follow-up questions

No follow-up questions available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

More Spring interview questions

View all →