Spring Boot Tutorial 0/110 lessons ~6 min read Lesson 87

    Environment Variables

    Twelve-factor app rule #3: store config in the environment.

    Course progress0%
    Focus
    2 guided sections
    Practice signal
    Examples included
    Career prep
    Foundation builder

    Introduction

    Twelve-factor app rule #3: store config in the environment. Spring Boot maps SPRING_DATASOURCE_URL automatically to spring.datasource.url.

    Informative example

    bash
    # Local
    export SPRING_PROFILES_ACTIVE=dev
    export DB_PASSWORD=secret
    ./mvnw spring-boot:run
    # Docker
    docker run -e SPRING_PROFILES_ACTIVE=prod -e DB_PASSWORD=${DB_PASSWORD} acme/orders
    # Kubernetes secret → env
    env:
    - name: DB_PASSWORD
    valueFrom: { secretKeyRef: { name: orders, key: db-password } }
    Ready to mark this lesson complete?Track your journey across the entire course.