0Pricing
Spring Boot 4 Microservices & REST APIs · Pelajaran

Server Konfigurasi

Sediakan konfigurasi dari server pusat.

Server Konfigurasi adalah pelajaran Spring Boot 4 Microservices & REST APIs gratis di CoddyKit. Ini adalah pelajaran 1 dari 4. Kamu bisa membaca pelajaran lengkapnya di bawah secara gratis — lalu praktikkan langsung di browser dengan editor kode bawaan dan tutor AI 24/7. Ini adalah bagian dari jalur belajar Spring Boot 4 Microservices & REST APIs, dan progresmu tersinkronisasi di web dan aplikasi CoddyKit. Kursus Spring Boot 4 Microservices & REST APIs mencakup 4 pelajaran total.

Bagian dari pelajaran ini belum diterjemahkan dan ditampilkan dalam bahasa Inggris.

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

Pertanyaan yang Sering Diajukan

Apakah pelajaran “Server Konfigurasi” gratis?

Ya — teks lengkap “Server Konfigurasi” gratis dibaca di sini di web. Untuk praktiknya secara interaktif (editor kode bawaan dan tutor AI 24/7) dan buka sisa kursus Spring Boot 4 Microservices & REST APIs, upgrade ke CoddyKit PRO. Kursus Spring Boot 4 Microservices & REST APIs mencakup 4 pelajaran total.

Apa yang akan aku pelajari di “Server Konfigurasi”?

Sediakan konfigurasi dari server pusat. Kamu berlatih Spring Boot 4 Microservices & REST APIs dengan kode praktik yang langsung kamu jalankan di browser, dan tutor AI 24/7 menjawab pertanyaanmu saat kamu mengerjakan pelajaran ini.

Apakah aku perlu pengalaman untuk memulai Spring Boot 4 Microservices & REST APIs?

Tidak diperlukan pengalaman sebelumnya. Spring Boot 4 Microservices & REST APIs di CoddyKit dirancang untuk pemula hingga pelajar tingkat lanjut, jadi kamu bisa memulai di sini atau dari awal dan belajar sesuai kecepatan kamu sendiri. Ini adalah pelajaran 1 dari 4.

Berapa lama pelajaran “Server Konfigurasi” memakan waktu?

Sebagian besar pelajaran CoddyKit memakan waktu sekitar 5–10 menit. Setiap pelajaran ringkas dan interaktif, jadi kamu membuat kemajuan stabil dan melanjutkan dari tempat kamu tinggalkan di web dan aplikasi.

Bisakah aku menulis dan menjalankan kode dalam pelajaran Spring Boot 4 Microservices & REST APIs ini?

Ya. Setiap pelajaran Spring Boot 4 Microservices & REST APIs menyertakan editor kode bawaan, jadi kamu menulis dan menjalankan kode nyata langsung di browser dan mendapatkan umpan balik AI instan — tidak diperlukan penyiapan lokal.

Semua pelajaran dalam kursus ini

  1. Server Konfigurasi
  2. Konfigurasi Berbasis Git
  3. Klien Konfigurasi
  4. Menyegarkan Konfigurasi saat Runtime
← Kembali ke Spring Boot 4 Microservices & REST APIs