Skip to content

Commit 8b30ad2

Browse files
committed
Merge pull request #16622 from Kedar Joshi
* pr/16622: Polish "Document use of @Profile with @ConfigurationProperties scanning" Document use of @Profile with @ConfigurationProperties scanning
2 parents 0b27f7c + d4435e0 commit 8b30ad2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,9 +1625,9 @@ property files>>.
16251625
[[boot-features-profiles]]
16261626
== Profiles
16271627
Spring Profiles provide a way to segregate parts of your application configuration and
1628-
make it be available only in certain environments. Any `@Component` or `@Configuration`
1629-
can be marked with `@Profile` to limit when it is loaded, as shown in the following
1630-
example:
1628+
make it be available only in certain environments. Any `@Component`, `@Configuration`
1629+
or `@ConfigurationProperties` can be marked with `@Profile` to limit when it is loaded,
1630+
as shown in the following example:
16311631

16321632
[source,java,indent=0]
16331633
----
@@ -1640,6 +1640,11 @@ example:
16401640
}
16411641
----
16421642

1643+
NOTE: If `@ConfigurationProperties` beans are registered via `@EnableConfigurationProperties`
1644+
instead of automatic scanning, the `@Profile` annotation needs to be specified on the `@Configuration`
1645+
class that has the `@EnableConfigurationProperties` annotation. In the case where `@ConfigurationProperties`
1646+
are scanned, `@Profile` can be specified on the `@ConfigurationProperties` class itself.
1647+
16431648
You can use a `spring.profiles.active` `Environment` property to specify which profiles
16441649
are active. You can specify the property in any of the ways described earlier in this
16451650
chapter. For example, you could include it in your `application.properties`, as shown in

0 commit comments

Comments
 (0)