Skip to content

Commit 09dc4e5

Browse files
committed
Merge branch '2.5.x' into 2.6.x
Closes gh-30113 Closes gh-30114
2 parents b86ad89 + ef7d748 commit 09dc4e5

File tree

1 file changed

+38
-1
lines changed
  • spring-boot-project/spring-boot-docs/src/docs/asciidoc/features

1 file changed

+38
-1
lines changed

spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/profiles.adoc

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,27 @@ The name of the default profile is `default` and it can be tuned using the confi
3434
default: "none"
3535
----
3636

37+
`spring.profiles.active` and `spring.profiles.default` can only be used in non-profile specific documents.
38+
This means they cannot be included in <<features#features.external-config.files.profile-specific,profile specific files>> or <<features#features.external-config.files.activation-properties,documents activated>> by `spring.config.activate.on-profile`.
39+
40+
For example, the second document configuration is invalid:
41+
42+
[source,yaml,indent=0,subs="verbatim",configprops,configblocks]
43+
----
44+
# this document is valid
45+
spring:
46+
profiles:
47+
active: "prod"
48+
---
49+
# this document is invalid
50+
spring:
51+
config:
52+
activate:
53+
on-profile: "prod"
54+
profiles:
55+
active: "metrics"
56+
----
57+
3758

3859

3960
[[features.profiles.adding-active-profiles]]
@@ -42,8 +63,24 @@ The configprop:spring.profiles.active[] property follows the same ordering rules
4263
This means that you can specify active profiles in `application.properties` and then *replace* them by using the command line switch.
4364

4465
Sometimes, it is useful to have properties that *add* to the active profiles rather than replace them.
45-
The `SpringApplication` entry point has a Java API for setting additional profiles (that is, on top of those activated by the configprop:spring.profiles.active[] property).
66+
The `spring.profiles.include` property can be used to add active profiles on top of those activated by the configprop:spring.profiles.active[] property.
67+
The `SpringApplication` entry point also has a Java API for setting additional profiles.
4668
See the `setAdditionalProfiles()` method in {spring-boot-module-api}/SpringApplication.html[SpringApplication].
69+
70+
For example, when an application with the following properties is run, the common and local profiles will be activated even when it runs using the --spring.profiles.active switch:
71+
72+
[source,yaml,indent=0,subs="verbatim",configprops,configblocks]
73+
----
74+
spring:
75+
profiles:
76+
include:
77+
- "common"
78+
- "local"
79+
----
80+
81+
WARNING: Similar to `spring.profiles.active`, `spring.profiles.include` can only be used in non-profile specific documents.
82+
This means it cannot be included in <<features#features.external-config.files.profile-specific,profile specific files>> or <<features#features.external-config.files.activation-properties,documents activated>> by `spring.config.activate.on-profile`.
83+
4784
Profile groups, which are described in the <<features#features.profiles.groups,next section>> can also be used to add active profiles if a given profile is active.
4885

4986

0 commit comments

Comments
 (0)