Improve "profile" reference documentation with additional admonitions
Build and Deploy Snapshot / Build and Deploy Snapshot (push) Waiting to run Details
Build and Deploy Snapshot / Trigger Docs Build (push) Blocked by required conditions Details
Build and Deploy Snapshot / Verify (push) Blocked by required conditions Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:windows-latest name:Windows]) (push) Waiting to run Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:21], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:21], map[id:windows-latest name:Windows]) (push) Waiting to run Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:22], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:22], map[id:windows-latest name:Windows]) (push) Waiting to run Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:23], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:23], map[id:windows-latest name:Windows]) (push) Waiting to run Details
Run System Tests / Java ${{ matrix.java.version}} (map[toolchain:false version:17]) (push) Waiting to run Details
Run System Tests / Java ${{ matrix.java.version}} (map[toolchain:true version:21]) (push) Waiting to run Details

Closes gh-45522
This commit is contained in:
Phillip Webb 2025-05-14 16:20:35 -07:00
parent ce900b1304
commit 34dee77a3e
2 changed files with 13 additions and 4 deletions

View File

@ -8,6 +8,8 @@ Property values can be injected directly into your beans by using the javadoc:or
Spring Boot uses a very particular javadoc:org.springframework.core.env.PropertySource[] order that is designed to allow sensible overriding of values. Spring Boot uses a very particular javadoc:org.springframework.core.env.PropertySource[] order that is designed to allow sensible overriding of values.
Later property sources can override the values defined in earlier ones. Later property sources can override the values defined in earlier ones.
[[features.external-config.order]]
Sources are considered in the following order: Sources are considered in the following order:
. Default properties (specified by setting javadoc:org.springframework.boot.SpringApplication#setDefaultProperties(java.util.Map)[]). . Default properties (specified by setting javadoc:org.springframework.boot.SpringApplication#setDefaultProperties(java.util.Map)[]).

View File

@ -53,16 +53,19 @@ spring:
active: "metrics" active: "metrics"
---- ----
The configprop:spring.profiles.active[] property follows the same ordering rules as other properties.
The highest javadoc:org.springframework.core.env.PropertySource[] wins.
This means that you can specify active profiles in `application.properties` and then *replace* them by using the command line switch.
TIP: See xref:features/external-config.adoc#features.external-config.order[the "`Externalized Configuration`"] for more details on the order in which property sources are considered.
[[features.profiles.adding-active-profiles]] [[features.profiles.adding-active-profiles]]
== Adding Active Profiles == Adding Active Profiles
The configprop:spring.profiles.active[] property follows the same ordering rules as other properties: The highest javadoc:org.springframework.core.env.PropertySource[] wins.
This means that you can specify active profiles in `application.properties` and then *replace* them by using the command line switch.
Sometimes, it is useful to have properties that *add* to the active profiles rather than replace them. Sometimes, it is useful to have properties that *add* to the active profiles rather than replace them.
The `spring.profiles.include` property can be used to add active profiles on top of those activated by the configprop:spring.profiles.active[] property. The configprop:spring.profiles.include[] property can be used to add active profiles on top of those activated by the configprop:spring.profiles.active[] property.
The javadoc:org.springframework.boot.SpringApplication[] entry point also has a Java API for setting additional profiles. The javadoc:org.springframework.boot.SpringApplication[] entry point also has a Java API for setting additional profiles.
See the `setAdditionalProfiles()` method in javadoc:org.springframework.boot.SpringApplication[]. See the `setAdditionalProfiles()` method in javadoc:org.springframework.boot.SpringApplication[].
@ -77,6 +80,10 @@ spring:
- "local" - "local"
---- ----
NOTE: Included profiles are added before any configprop:spring.profiles.active[] profiles.
TIP: The configprop:spring.profiles.include[] property is processed for each property source, as such the usual xref:features/external-config.adoc#features.external-config.typesafe-configuration-properties.merging-complex-types[complex type merging rules] for lists do not apply.
WARNING: Similar to `spring.profiles.active`, `spring.profiles.include` can only be used in non-profile-specific documents. WARNING: Similar to `spring.profiles.active`, `spring.profiles.include` can only be used in non-profile-specific documents.
This means it cannot be included in xref:features/external-config.adoc#features.external-config.files.profile-specific[profile specific files] or xref:features/external-config.adoc#features.external-config.files.activation-properties[documents activated] by `spring.config.activate.on-profile`. This means it cannot be included in xref:features/external-config.adoc#features.external-config.files.profile-specific[profile specific files] or xref:features/external-config.adoc#features.external-config.files.activation-properties[documents activated] by `spring.config.activate.on-profile`.