Configurazione supportata da Git
Versioni la configurazione in un repository Git.
Configurazione supportata da Git è una lezione Spring Boot 4 Microservices & REST APIs gratuita su CoddyKit. Questa è la lezione 2 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Spring Boot 4 Microservices & REST APIs, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Spring Boot 4 Microservices & REST APIs include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
Why Git as the backend
Storing configuration in Git gives you version history, code review, and rollback. The Config Server simply reads files from a configured repository.
The config repo layout
Each service has one or more YAML/properties files named after its application name, optionally with a profile suffix.
// config-repo/
// application.yml (shared by all)
// orders.yml (orders, default profile)
// orders-prod.yml (orders, prod profile)
// inventory.ymlShared application.yml
A file literally named application.yml holds defaults applied to every client. Put cross-cutting settings (logging, common URLs) here.
Profile-specific overrides
Profile files like orders-prod.yml override the base orders.yml for that profile. The server merges them, with the profile file taking precedence.
Pointing the server at the repo
Set the Git URI on the server. For private repos add credentials or an SSH key.
spring:
cloud:
config:
server:
git:
uri: https://github.com/acme/config-repo
username: ci-bot
password: ${GIT_TOKEN}Choosing a branch (label)
The Git label defaults to main/master but can be any branch or tag. Clients can request a specific label, enabling per-environment branches.
server:
cloud:
config:
server:
git:
default-label: release-2026Search paths in the repo
If config lives in subfolders, set search-paths so the server looks in the right places. Placeholders like {application} are supported.
spring:
cloud:
config:
server:
git:
uri: https://github.com/acme/config-repo
search-paths: "{application}"Cloning behavior
The server clones the repo on first request (or eagerly). With clone-on-start: true it fails fast at boot if the repo is unreachable, surfacing misconfiguration early.
spring:
cloud:
config:
server:
git:
clone-on-start: truePicking up new commits
On each client request the server checks for new commits. So pushing a change to the repo makes it available - clients still need to be refreshed to apply it (covered later).
Multiple repos
You can map different applications or patterns to different repositories, e.g. keep secrets in a separate, tightly-controlled repo.
spring:
cloud:
config:
server:
git:
uri: https://github.com/acme/general-config
repos:
secure:
pattern: payments-*
uri: https://github.com/acme/secure-configKeeping secrets safe
Even in Git, never commit plaintext secrets. Use the server's {cipher} encryption or an external secret manager, and restrict repo access.
Quick Check
Verify your Git-backend understanding.
Recap
You backed config with Git:
- Files named by application + optional profile suffix
application.yml= shared defaults;app-profile.ymloverrides- Configure URI, label (branch), search-paths and credentials
- Keep secrets encrypted, never plaintext
Domande Frequenti
La lezione «Configurazione supportata da Git» è gratuita?
Sì — il testo completo di «Configurazione supportata da Git» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Spring Boot 4 Microservices & REST APIs, passa a CoddyKit PRO. Il corso Spring Boot 4 Microservices & REST APIs include 4 lezioni in totale.
Cosa imparerò in «Configurazione supportata da Git»?
Versioni la configurazione in un repository Git. Eserciti Spring Boot 4 Microservices & REST APIs con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare Spring Boot 4 Microservices & REST APIs?
Non è richiesta alcuna esperienza precedente. Spring Boot 4 Microservices & REST APIs su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 2 di 4.
Quanto tempo richiede la lezione «Configurazione supportata da Git»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione Spring Boot 4 Microservices & REST APIs?
Sì. Ogni lezione Spring Boot 4 Microservices & REST APIs include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Il Config Server
- Configurazione supportata da Git
- Client di configurazione
- Aggiornare la configurazione durante l'esecuzione