SPRING CONCEPTS

Environment variables

Spring Concepts / Environment variables

Environment variables supply configuration to a running process.

Understand the idea

Spring property placeholders read deployment values from the environment. A terminal assignment applies to that terminal and its child processes. An IDE run configuration needs its own launch environment. Keep secrets out of checked-in files and browser code.

A concrete example

spring.mongodb.uri=${MONGODB_URI}
app.jwt.secret=${JWT_SECRET}

In the application

MONGODB_URI configures Atlas for all backends; JWT_SECRET supplies the personal API signing key.

Spring does not automatically load an arbitrary .env file. Variables set in one terminal do not automatically reach an already-running IDE.

Related concepts

Read the official documentation ↗
Java 21 · Spring Boot 4.1.1 · Edupoly