Spring Boot Tutorial 0/110 lessons ~6 min read Lesson 51
Environment Configuration
12-factor apps configure via the environment.
Course progress0%
Focus
3 guided sections
Practice signal
Examples included
Career prep
Foundation builder
Introduction
12-factor apps configure via the environment. In Kubernetes that's a ConfigMap + Secret; locally it's .env; in CI it's pipeline variables.
Informative example
bash
# application.yml — env vars with defaultsspring:datasource:url: ${DB_URL:jdbc:postgresql://localhost:5432/orders}username: ${DB_USER:postgres}password: ${DB_PASSWORD} # required, no defaultstripe:api-key: ${STRIPE_API_KEY} # secret
Best practices
- Secrets in env vars, never in YAML committed to git.
- Use a secrets manager (Vault, AWS Secrets Manager) — mount as env or files.
- Fail fast on missing required vars at startup.
Ready to mark this lesson complete?Track your journey across the entire course.