Spring profile
A named set of configuration, such as local, test or production, that Spring activates to change properties and beans for one environment.
In more detail
The default configuration should be a safe baseline, and an active profile should add only the differences. Profile-specific beans can swap a fake client for tests. Profiles are not feature flags: changing one changes the application context and needs a restart.
Example
SPRING_PROFILES_ACTIVE=productionRelated terms
- application properties — Settings a Spring Boot application reads at startup from files such as application.properties, environment variables and command-line arguments.
- feature flag — A switch in the code, controlled from outside, that turns a feature on or off for chosen users without a new deployment.
- conditional configuration — Spring configuration that only applies when a condition holds, such as a class being present, a property being set or no other bean of that type existing.
Taught in
- Spring Boot Auto Configuration — Modern Java: Virtual Threads & High-Throughput Services
- Configuration And Profiles — Modern Java: Virtual Threads & High-Throughput Services