Commit 8b30ad21 authored by Madhura Bhave's avatar Madhura Bhave

Merge pull request #16622 from Kedar Joshi

* pr/16622:
  Polish "Document use of @Profile with @ConfigurationProperties scanning"
  Document use of @Profile with @ConfigurationProperties scanning
parents 0b27f7c7 d4435e01
...@@ -1625,9 +1625,9 @@ property files>>. ...@@ -1625,9 +1625,9 @@ property files>>.
[[boot-features-profiles]] [[boot-features-profiles]]
== Profiles == Profiles
Spring Profiles provide a way to segregate parts of your application configuration and Spring Profiles provide a way to segregate parts of your application configuration and
make it be available only in certain environments. Any `@Component` or `@Configuration` make it be available only in certain environments. Any `@Component`, `@Configuration`
can be marked with `@Profile` to limit when it is loaded, as shown in the following or `@ConfigurationProperties` can be marked with `@Profile` to limit when it is loaded,
example: as shown in the following example:
[source,java,indent=0] [source,java,indent=0]
---- ----
...@@ -1640,6 +1640,11 @@ example: ...@@ -1640,6 +1640,11 @@ example:
} }
---- ----
NOTE: If `@ConfigurationProperties` beans are registered via `@EnableConfigurationProperties`
instead of automatic scanning, the `@Profile` annotation needs to be specified on the `@Configuration`
class that has the `@EnableConfigurationProperties` annotation. In the case where `@ConfigurationProperties`
are scanned, `@Profile` can be specified on the `@ConfigurationProperties` class itself.
You can use a `spring.profiles.active` `Environment` property to specify which profiles You can use a `spring.profiles.active` `Environment` property to specify which profiles
are active. You can specify the property in any of the ways described earlier in this are active. You can specify the property in any of the ways described earlier in this
chapter. For example, you could include it in your `application.properties`, as shown in chapter. For example, you could include it in your `application.properties`, as shown in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment