Demo: diagnosing an ambiguous-bean startup failure
On This Lesson 3 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
read the failure message and fix it three ways; prepares the assessment.
Draft outline details
Step by step
- Add a second
PaymentProviderimplementation and start the app. - Read the report: it says
expected single matching bean but found 2and lists both names. - Planned mistake: "fix" it by deleting one implementation. Explain why that removes a needed feature.
- Fix 1:
@Primaryon the default. Fix 2:@Qualifier("paypal")at the injection point. - Fix 3: inject
Map<String, PaymentProvider>and choose by key at run time. - Run again and confirm the app starts.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.