การกำหนดค่าที่มี Git รองรับ
จัดเก็บเวอร์ชันการกำหนดค่าในคลัง Git
การกำหนดค่าที่มี Git รองรับ เป็นบทเรียน Spring Boot 4 Microservices & REST APIs ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Spring Boot 4 Microservices & REST APIs และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Spring Boot 4 Microservices & REST APIs มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
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
คำถามที่พบบ่อย
บทเรียน “การกำหนดค่าที่มี Git รองรับ” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “การกำหนดค่าที่มี Git รองรับ” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Spring Boot 4 Microservices & REST APIs ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Spring Boot 4 Microservices & REST APIs มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “การกำหนดค่าที่มี Git รองรับ”
จัดเก็บเวอร์ชันการกำหนดค่าในคลัง Git คุณปฏิบัติ Spring Boot 4 Microservices & REST APIs ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Spring Boot 4 Microservices & REST APIs หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Spring Boot 4 Microservices & REST APIs บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน
บทเรียน “การกำหนดค่าที่มี Git รองรับ” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Spring Boot 4 Microservices & REST APIs นี้ได้ไหม
ได้ บทเรียน Spring Boot 4 Microservices & REST APIs ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- เซิร์ฟเวอร์การกำหนดค่า
- การกำหนดค่าที่มี Git รองรับ
- ไคลเอนต์การกำหนดค่า
- การรีเฟรชการกำหนดค่าขณะทำงาน