عرض عملي: استبدال المستودع في الذاكرة بـ Spring JDBC
في هذا الدرس 3 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
swap the Shop repository implementation without touching controllers or services; prepares JNR-026-LAB1.
تفاصيل المخطط المبدئي
خطوة بخطوة
- Show the existing
ProductRepositoryinterface and the in-memory implementation. - Apply
schema.sqlmanually in local PostgreSQL and add the datasource properties. - Create
JdbcProductRepository implements ProductRepositoryusingJdbcClientand a shared mapper. - Planned mistake: forget the
@Repository/bean switch so two implementations exist; show the startup error and remove the in-memory bean. - Run the existing API tests; they pass unchanged.
- Add one integration test against a real PostgreSQL database.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.