Skip to content

Commit eb49f4b

Browse files
author
Dave Syer
committed
Documentation for default profiles
1 parent dc8ba2c commit eb49f4b

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,13 @@ environment variables or system properties.
380380
[[boot-features-external-config-profile-specific-properties]]
381381
=== Profile-specific properties
382382
In addition to `application.properties` files, profile-specific properties can also be
383-
defined using the naming convention `application-{profile}.properties`.
383+
defined using the naming convention `application-{profile}.properties`. The
384+
`Environment` has a set of default profiles (by default `[default]`) which are
385+
used if no active profiels are set (i.e. if no profiles are explicitly activated
386+
then properties from `application-default.properties` are loaded).
384387

385388
Profile specific properties are loaded from the same locations as standard
386-
`application.properties`, with profile-specific files always overriding the default
389+
`application.properties`, with profile-specific files always overriding the non-specific
387390
ones irrespective of whether the profile-specific files are inside or outside your
388391
packaged jar.
389392

@@ -518,8 +521,35 @@ using a `spring.profiles` key to indicate when the document applies. For example
518521

519522
In the example above, the `server.address` property will be `127.0.0.1` if the
520523
`development` profile is active. If the `development` and `production` profiles are *not*
521-
enabled, then the value for the property will be `192.168.1.100`
524+
enabled, then the value for the property will be `192.168.1.100`.
522525

526+
The default profiles are activated if none are explicitly active when the application
527+
context starts. So in this YAML we set a value for `security.user.password` that is
528+
*only* available in the "default" profile:
529+
530+
[source,yaml,indent=0]
531+
----
532+
server:
533+
port: 80000
534+
---
535+
spring:
536+
profiles: default
537+
security:
538+
user:
539+
password: weak
540+
----
541+
542+
whereas in this example, the password is always set because it isn't attached to any profile,
543+
and it would have to be explicitly reset in all other profiles as necessary:
544+
545+
[source,yaml,indent=0]
546+
----
547+
server:
548+
port: 80000
549+
security:
550+
user:
551+
password: weak
552+
----
523553

524554

525555
[[boot-features-external-config-yaml-shortcomings]]

0 commit comments

Comments
 (0)