Spring Boot
في هذه الصفحة 8 موضوعات
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
نظرة عامة
الموضوعات
- Starters
- الإعداد التلقائي (Auto-configuration)
- هيكل المشروع
- الخوادم المضمّنة
تعلّم أولًا
2 ساعة تدريب (تقدير)
مخرجات التعلم
- Explain starters and how auto-configuration decides what to create (conditions).
- Read the conditions evaluation report to see why something was or was not configured.
- Override an auto-configured bean.
- Describe the embedded server and build an executable JAR.
الدروس
المختبر والتمارين
Lab
JNR-011-LAB1 · Under the hood
Outcomes: 1–4 · Time: ~2 h
- Run the Shop API with
--debugand save the conditions evaluation report. - Pick three auto-configurations that applied (positive matches) and one that did not (negative match); for each, write the condition that decided it.
- Override the default JSON date format (property first, then customizer).
- Build the executable JAR and run it with
java -jar.
Acceptance: written explanation matches the report; date format changed; JAR runs.
Exercises (assessment: explain the startup sequence of the Shop API)
| ID | Outcome | Task |
|---|---|---|
| JNR-011-EX01 | 1 | Explain in three sentences what a starter and an auto-configuration are and how they differ. |
| JNR-011-EX02 | 1 | Name the three conditions @ConditionalOnClass, @ConditionalOnMissingBean, @ConditionalOnProperty and give one example of each. |
| JNR-011-EX03 | 2 | In the report, find why a DataSource was not created in a project without a database starter. |
| JNR-011-EX04 | 3 | Define your own Clock or ObjectMapper bean and confirm in the report that Boot's default backed off. |
| JNR-011-EX05 | 4 | Build the JAR, list its contents with jar tf, and find the embedded server library. |
| JNR-011-EX06 | 4 | Write the startup sequence of the Shop API: main, SpringApplication.run, context creation, scanning, auto-configuration, server start, "Started". |
أظهر الحلول
- EX01 A starter is a dependency bundle; auto-configuration is the code, triggered by what is on the classpath, that creates beans. Starter supplies the libraries; auto-configuration wires them.
- EX02 Class present (Tomcat classes); missing bean (no user-defined
ObjectMapper); property (spring.main.banner-mode, or a feature flag). - EX03 Negative match: required classes, or a bean of the needed type, are absent.
- EX04 The report lists the default bean under negative matches with
@ConditionalOnMissingBeanfound a bean. - EX05
jar tf target/*.jarshowsBOOT-INF/lib/tomcat-embed-core-*.jar. - EX06
maincallsrun; Boot prepares the environment and creates the context; scanning finds your beans; auto-configuration adds the defaults; the embedded server starts; the app logs "Started".
الاختبار
Outcomes: O1 starters and auto-configuration · O2 conditions report · O3 overriding · O4 embedded server and JAR.
اختبار ذاتي لك: لا توجد درجات، ولا يُحفظ أو يُرسل أي شيء. اختر إجابة ثم تحقق منها، ويمكنك المحاولة مرة أخرى كما تشاء.
الجزء العملي
Six exercises JNR-011-EX01 to EX06 plus the lab. The assessment is EX06: explaining the Shop API startup sequence. Pass: quiz at least 8/10, the lab explanation matches the report, EX06 correct.
أخطاء شائعة
Treating auto-configuration as magic; excluding auto-configurations blindly.
التقييم
Explain the startup sequence of the Shop API.
الصلة بالمسار الوظيفي
Troubleshooting configuration issues in real services.