Harici ve Geçersiz Kılan Yapılandırma
Yapılandırmayı ortam ve komut satırı üzerinden geçersiz kılın.
Harici ve Geçersiz Kılan Yapılandırma, CoddyKit'te ücretsiz bir Spring Boot 4 Microservices & REST APIs dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Spring Boot 4 Microservices & REST APIs öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Spring Boot 4 Microservices & REST APIs kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
The 12-Factor Idea
A core principle of portable apps is storing configuration in the environment, not in code. The same artifact should run anywhere, with behavior changed only by external config.
Spring Boot embraces this: a single jar reads from many sources and merges them with a well-defined precedence.
Many Sources, One Environment
Boot collects configuration from numerous property sources — files, environment variables, command-line args, and more — into one unified Environment.
- Each source contributes key/value pairs
- Higher-priority sources win on conflicts
- Your code never knows or cares where a value came from
Precedence Order (High to Low)
When the same key appears in several sources, the highest-priority source wins. A simplified, commonly used ordering:
- Command-line arguments
- OS environment variables
- Profile-specific
application-{profile}files - Base
applicationfiles - Defaults in code /
@Valuefallbacks
This is why a CLI flag can override anything baked into the jar.
Overriding with Command-Line Args
Pass --key=value after the jar. These have very high precedence and are ideal for one-off overrides or container entrypoints.
java -jar app.jar \
--server.port=9090 \
--spring.profiles.active=prod \
--app.mail.host=smtp.prod.example.comOverriding with Environment Variables
Environment variables use an UPPER_SNAKE_CASE form of the property name: dots and dashes become underscores. This is the standard way to inject config in containers.
# property: app.mail.host
export APP_MAIL_HOST=smtp.prod.example.com
# property: server.port
export SERVER_PORT=9090
# property: spring.datasource.password
export SPRING_DATASOURCE_PASSWORD=s3cretRelaxed Binding for Env Vars
Because env var names are constrained, Spring maps them back to canonical property names. APP_MAIL_MAX_RETRIES resolves to app.mail.maxRetries. This lets you set any property from the environment.
Injecting Secrets at Deploy Time
Keep secrets out of the jar; reference them with placeholders and let the platform supply real values via env vars. The committed file holds only a safe default or none.
spring:
datasource:
url: ${DB_URL}
username: ${DB_USER:app}
password: ${DB_PASSWORD}External Config Files
Point Boot at config outside the jar with spring.config.location or add extra files with spring.config.additional-location. Operators can drop a file next to the deployment without rebuilding.
java -jar app.jar \
--spring.config.additional-location=file:/etc/myapp/Importing Config
Modern Boot supports spring.config.import to pull in extra documents, optional files, or even config server entries, merged with the normal precedence rules.
spring:
config:
import:
- optional:file:/etc/myapp/override.yml
- configserver:Random Values
The random property source generates values on demand — handy for test data or ephemeral identifiers, though not for stable secrets.
app:
instance-id: ${random.uuid}
jitter-ms: ${random.int(0,500)}Debugging Where a Value Came From
When a value is not what you expect, inspect the merged Environment. The actuator /env endpoint lists every property source and the winning value, making precedence problems easy to diagnose.
# requires spring-boot-starter-actuator + exposure
GET /actuator/env/server.portQuick Check
Test your understanding of precedence.
Recap
Externalized config makes one artifact run everywhere.
- Many sources merge into one
Environmentby precedence - CLI args > env vars > profile files > base files > code defaults
- Env vars use UPPER_SNAKE_CASE relaxed binding
- Inject secrets via placeholders at deploy time
- Use
/actuator/envto debug where a value originated
Sıkça Sorulan Sorular
“Harici ve Geçersiz Kılan Yapılandırma” dersi ücretsiz mi?
Evet — “Harici ve Geçersiz Kılan Yapılandırma” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Spring Boot 4 Microservices & REST APIs kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Spring Boot 4 Microservices & REST APIs kursu toplamda 4 dersten oluşur.
“Harici ve Geçersiz Kılan Yapılandırma” dersinde ne öğreneceğim?
Yapılandırmayı ortam ve komut satırı üzerinden geçersiz kılın. Spring Boot 4 Microservices & REST APIs ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
Spring Boot 4 Microservices & REST APIs öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te Spring Boot 4 Microservices & REST APIs, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.
“Harici ve Geçersiz Kılan Yapılandırma” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu Spring Boot 4 Microservices & REST APIs dersinde kod yazıp çalıştırabilir miyim?
Evet. Her Spring Boot 4 Microservices & REST APIs dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- application.properties ve YAML
- Ortamlar için Profiller
- @ConfigurationProperties ile Tür Güvenli Yapılandırma
- Harici ve Geçersiz Kılan Yapılandırma