0Pricing
Spring Boot 4 Microservices & REST APIs · درس

خادم الإعدادات

قدّم الإعدادات من خادم مركزي

خادم الإعدادات درس مجاني في Spring Boot 4 Microservices & REST APIs على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Spring Boot 4 Microservices & REST APIs، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Spring Boot 4 Microservices & REST APIs 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

The configuration problem

In a microservices system, many services each need configuration. Duplicating application.yml everywhere is error-prone. Spring Cloud Config centralizes configuration in one server.

What the Config Server does

The Config Server is a small Spring Boot app that serves configuration to client services over HTTP, typically backed by a Git repository.

  • One place to view and change config
  • Versioned, auditable changes

Adding the server dependency

Create a new app and add spring-cloud-config-server.

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-config-server</artifactId>
</dependency>

@EnableConfigServer

Annotate the main class with @EnableConfigServer to turn the app into a Config Server.

@SpringBootApplication
@EnableConfigServer
public class ConfigServerApp {
    public static void main(String[] args) {
        SpringApplication.run(ConfigServerApp.class, args);
    }
}

Pointing at a backend

The server needs a backend to read config from. The most common is a Git repo, set with spring.cloud.config.server.git.uri.

# application.yml of the server
spring:
  cloud:
    config:
      server:
        git:
          uri: https://github.com/acme/config-repo

Running on a known port

Config Servers conventionally run on port 8888 so clients can find them with default settings.

server:
  port: 8888

How config is addressed

The server resolves config by application name and profile. A client named orders with profile prod maps to files like orders-prod.yml in the repo.

The server HTTP API

You can query the server directly. The path is /{application}/{profile} and it returns the merged properties as JSON.

// GET http://localhost:8888/orders/prod
// returns merged config for app=orders, profile=prod

Native (filesystem) backend

For local development you can use a filesystem backend instead of Git via the native profile - convenient but not versioned.

spring:
  profiles:
    active: native
  cloud:
    config:
      server:
        native:
          search-locations: file:./config

Securing the server

Config can contain secrets, so protect the server with HTTP Basic auth (Spring Security) and run it behind your private network. Clients then send credentials.

Encryption support

The server can store encrypted values (prefixed {cipher}) and decrypt them on the fly, so secrets are never stored in plaintext in the repo - provided a key is configured.

Quick Check

Check your Config Server fundamentals.

Recap

You stood up a Config Server:

  • It centralizes config and serves it over HTTP
  • @EnableConfigServer + a Git (or native) backend
  • Runs on port 8888 by convention
  • Resolves config by application name and profile

الأسئلة الشائعة

هل درس «خادم الإعدادات» مجاني؟

نعم — نص درس «خادم الإعدادات» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Spring Boot 4 Microservices & REST APIs، انتقل إلى CoddyKit PRO. تتضمن دورة Spring Boot 4 Microservices & REST APIs 4 دروس في المجموع.

ماذا ستتعلم في «خادم الإعدادات»؟

قدّم الإعدادات من خادم مركزي تتمرن على Spring Boot 4 Microservices & REST APIs مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Spring Boot 4 Microservices & REST APIs؟

لا تُشترط خبرة سابقة. Spring Boot 4 Microservices & REST APIs على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.

كم من الوقت يستغرق درس «خادم الإعدادات»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Spring Boot 4 Microservices & REST APIs هذا؟

نعم. كل درس في Spring Boot 4 Microservices & REST APIs يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. خادم الإعدادات
  2. الإعدادات المدعومة من Git
  3. عملاء الإعدادات
  4. تحديث الإعدادات أثناء التشغيل
← العودة إلى Spring Boot 4 Microservices & REST APIs