التحقق من الإعدادات
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
fail fast on bad settings.
الموضوعات المخطط لها
- Add
@Validatedto the properties type and bean validation constraints to its components. - If a value is missing or invalid, startup fails with a message naming the property.
- Failing at startup beats a failure at 3 a.m. on the first request.
- Use sensible constraints:
@NotBlank,@Min,@DecimalMin.
تفاصيل المخطط المبدئي
عرض عملي
@Validated @ConfigurationProperties("shop")
public record ShopProperties(
@NotBlank String currency,
@DecimalMin("0.00") @DecimalMax("1.00") BigDecimal taxRate,
@Min(1) @Max(100) int pageSizeMax) {}اختبر فهمك
When is a bad value detected?
أظهر الإجابة
At startup, before the app serves traffic.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.