الإعداد المركزي باستخدام Spring Cloud Config
أديروا إعدادات العديد من الخدمات المصغّرة في مكان واحد باستخدام Spring Cloud Config Server ومصادر الخصائص الخارجية.
الإعداد المركزي باستخدام Spring Cloud Config درس مجاني في Spring Boot 4 Complete Guide على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Spring Boot 4 Complete Guide، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Spring Boot 4 Complete Guide 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
The Configuration Problem at Scale
With dozens of microservices, scattering properties across each one becomes unmanageable. Centralized configuration stores settings in one source that every service reads from.
What Is Spring Cloud Config?
Spring Cloud Config provides a Config Server that serves configuration to client services, typically backed by a Git repository for versioning and auditability.
Setting Up the Config Server
Annotate a Spring Boot app with @EnableConfigServer to turn it into a configuration hub.
@EnableConfigServer
@SpringBootApplication
public class ConfigServerApp {
}Pointing to a Git Backend
Configure the server to read from a Git repo. Each service's properties live as files in that repo.
spring.cloud.config.server.git.uri=https://github.com/org/config-repoFile Naming Convention
Config files are named by application and profile, such as order-service-prod.yml. The server matches requests to the right file.
- application.yml — shared defaults
- order-service.yml — per service
- order-service-prod.yml — per profile
Making a Service a Config Client
A client service adds the config client starter and declares which application name and Config Server to use.
spring.application.name=order-service
spring.config.import=configserver:http://localhost:8888How Clients Fetch Config
On startup, the client contacts the Config Server, downloads its properties, and merges them into its environment before the rest of the app initializes.
Refreshing Without Restart
The @RefreshScope annotation lets beans pick up new values when you POST to the /actuator/refresh endpoint, avoiding full restarts.
@RefreshScope
@Component
public class FeatureFlags {
}Securing Sensitive Values
Secrets like passwords should be encrypted. The Config Server supports encrypting values so the Git repo never stores plaintext credentials.
Profiles and Environments
By using profile-specific files, the same service binary picks up dev, staging, or prod settings simply by activating the matching profile.
Why This Pattern Wins
Centralized, versioned, refreshable config means you change a setting once, audit who changed it, and roll it out without rebuilding services.
Quick Check
Test your understanding of centralized configuration.
Recap
You set up a Config Server backed by Git, connected client services, used profile-specific files, and enabled live refresh with @RefreshScope. Centralized config keeps a fleet of microservices consistent and manageable.
الأسئلة الشائعة
هل درس «الإعداد المركزي باستخدام Spring Cloud Config» مجاني؟
نعم — نص درس «الإعداد المركزي باستخدام Spring Cloud Config» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Spring Boot 4 Complete Guide، انتقل إلى CoddyKit PRO. تتضمن دورة Spring Boot 4 Complete Guide 4 دروس في المجموع.
ماذا ستتعلم في «الإعداد المركزي باستخدام Spring Cloud Config»؟
أديروا إعدادات العديد من الخدمات المصغّرة في مكان واحد باستخدام Spring Cloud Config Server ومصادر الخصائص الخارجية. تتمرن على Spring Boot 4 Complete Guide مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Spring Boot 4 Complete Guide؟
لا تُشترط خبرة سابقة. Spring Boot 4 Complete Guide على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.
كم من الوقت يستغرق درس «الإعداد المركزي باستخدام Spring Cloud Config»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Spring Boot 4 Complete Guide هذا؟
نعم. كل درس في Spring Boot 4 Complete Guide يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- مبادئ وتصميم الخدمات المصغّرة
- اكتشاف الخدمات وتسجيلها
- بوابة API باستخدام Spring Cloud Gateway
- الإعداد المركزي باستخدام Spring Cloud Config