عرض عملي: تشخيص فشل بدء التشغيل بسبب Bean غامض
في هذا الدرس 3 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
read the failure message and fix it three ways; prepares the assessment.
تفاصيل المخطط المبدئي
خطوة بخطوة
- 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.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.