Spring Boot profiles and externalized configuration
Answer: Spring Profiles provide a way to segregate parts of your application configuration and make it be available only in certain environments. (S1) Activate them with spring.profiles.active, for example --spring.profiles.active=dev. Profile-specific files like application-dev.yml override application.yml, and Spring Boot's ordered property sources let environment variables or command-line arguments override both.
# application.yml
server:
port: 8080
---
spring:
config:
activate:
on-profile: dev
server:
port: 9090
@Configuration
@Profile("production")
public class ProductionConfiguration { }
java -jar app.jar --spring.profiles.active=dev,hsqldb
SPRING_PROFILES_ACTIVE=prod java -jar app.jar
Rules
- If no profile is active, the
defaultprofile is used. @Profilealso works on@ConfigurationPropertiesclasses.- Sources include properties files, YAML, environment variables and arguments.
- Later sources override earlier ones; command-line arguments rank high.
Claims
- id: C1 claim: Spring Profiles make configuration available only in certain environments. source: S1 evidence: "Spring Profiles provide a way to segregate parts of your application configuration"
- id: C2 claim: spring.profiles.active specifies which profiles are active. source: S1 evidence: "You can use a spring.profiles.active Environment property to specify which profiles are active."
- id: C3 claim: If no profile is active, a default profile is enabled. source: S1 evidence: "If no profile is active, a default profile is enabled."
- id: C4 claim: Later property sources can override earlier ones. source: S2 evidence: "Later property sources can override the values defined in earlier ones."
- id: C5 claim: Sources include properties files, YAML, environment variables and arguments. source: S2 evidence: "Java properties files, YAML files, environment variables, and command-line arguments."
Sources
- [S1] Profiles :: Spring Boot. Spring (VMware/Broadcom). https://docs.spring.io/spring-boot/reference/features/profiles.html . License: Apache-2.0 (spring-projects repos). Accessed 2026-11-04.
- [S2] Externalized Configuration :: Spring Boot. Spring (VMware/Broadcom). https://docs.spring.io/spring-boot/reference/features/external-config.html . License: Apache-2.0 (spring-projects repos). Accessed 2026-11-04.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Spring (VMware/Broadcom), Profiles :: Spring Boot, Apache-2.0 (spring-projects repos); Spring (VMware/Broadcom), Externalized Configuration :: Spring Boot, Apache-2.0 (spring-projects repos).
Cite this
iinventedlight. 2026. "Spring Boot profiles and externalized configuration." iinventedlight Library, iil:note:5dy22b3w, version of 2026-11-04. https://iinventedlight.com/library/notes/spring-boot-profiles/. License: CC-BY-4.0.
@misc{iil_note_5dy22b3w,
author = {{iinventedlight}},
title = {{Spring Boot profiles and externalized configuration}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-04},
url = {https://iinventedlight.com/library/notes/spring-boot-profiles/},
note = {Permanent ID iil:note:5dy22b3w. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.
For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/spring-boot-profiles.md.