Zentrale Konfiguration mit Spring Cloud Config
Verwalten Sie die Konfiguration vieler Microservices an einer zentralen Stelle mit Spring Cloud Config Server und ausgelagerten Property-Quellen.
Zentrale Konfiguration mit Spring Cloud Config ist eine kostenlose Spring Boot 4 Complete Guide-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Spring Boot 4 Complete Guide-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Spring Boot 4 Complete Guide-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
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.
Lerne Java mit einem KI-Tutor — kostenlos
Schreibe und führe echten Code in deinem Browser aus, bekomme sofortige Hilfe von einem 24/7 KI-Tutor und setze dein Lernen im Web oder in der App fort.
- Kurse
- 21
- Lektionen
- 84
Häufig gestellte Fragen
Ist die Lektion „Zentrale Konfiguration mit Spring Cloud Config“ kostenlos?
Ja — der vollständige Text von „Zentrale Konfiguration mit Spring Cloud Config“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Spring Boot 4 Complete Guide-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Spring Boot 4 Complete Guide-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Zentrale Konfiguration mit Spring Cloud Config“?
Verwalten Sie die Konfiguration vieler Microservices an einer zentralen Stelle mit Spring Cloud Config Server und ausgelagerten Property-Quellen. Du übst Spring Boot 4 Complete Guide mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Spring Boot 4 Complete Guide zu starten?
Keine Vorkenntnisse erforderlich. Spring Boot 4 Complete Guide auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.
Wie lange dauert die Lektion „Zentrale Konfiguration mit Spring Cloud Config“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Spring Boot 4 Complete Guide-Lektion Code schreiben und ausführen?
Ja. Jede Spring Boot 4 Complete Guide-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Prinzipien und Design von Microservices
- Service-Erkennung und -Registrierung
- API-Gateway mit Spring Cloud Gateway
- Zentrale Konfiguration mit Spring Cloud Config