---
source: https://iinventedlight.com/library/notes/spring-boot-profiles.md
title: "Spring Boot profiles and externalized configuration"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (spring-projects repos); prose restates cited source lines"
attribution: "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)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-04
status: published
checked_on: 2026-11-04
as_of: 2026-11-04
confidence: medium
untested: "No code was run for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-ai-eng: Spring"
tags: ['spring-boot', 'java', 'configuration', 'profiles']
sources:
  - id: S1
    title: "Profiles :: Spring Boot"
    publisher: Spring (VMware/Broadcom)
    url: https://docs.spring.io/spring-boot/reference/features/profiles.html
    accessed: 2026-11-04
    license: "Apache-2.0 (spring-projects repos)"
  - id: S2
    title: "Externalized Configuration :: Spring Boot"
    publisher: Spring (VMware/Broadcom)
    url: https://docs.spring.io/spring-boot/reference/features/external-config.html
    accessed: 2026-11-04
    license: "Apache-2.0 (spring-projects repos)"
---
# 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.

```yaml
# application.yml
server:
  port: 8080
---
spring:
  config:
    activate:
      on-profile: dev
server:
  port: 9090
```

```java
@Configuration
@Profile("production")
public class ProductionConfiguration { }
```

```bash
java -jar app.jar --spring.profiles.active=dev,hsqldb
SPRING_PROFILES_ACTIVE=prod java -jar app.jar
```

## Rules

- If no profile is active, the `default` profile is used.
- `@Profile` also works on `@ConfigurationProperties` classes.
- 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).
