Skip to content

Commit 69c92f9

Browse files
committed
Document when to use multiple property placeholder configurers
This commit adds a warning in the reference guide to address the use cases where users might be tempted to use several property placeholder configurers. Closes gh-14623
1 parent 875eeab commit 69c92f9

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

framework-docs/modules/ROOT/pages/core/appendix/xsd-schemas.adoc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,17 @@ is a convenience mechanism that sets up a xref:core/beans/factory-extension.adoc
565565
for you. If you need more control over the specific
566566
`PropertySourcesPlaceholderConfigurer` setup, you can explicitly define it as a bean yourself.
567567

568+
[WARNING]
569+
=====
570+
Only one such element should be defined for a given application with the properties
571+
that it needs. Several property placeholders can be configured as long as they have distinct
572+
placeholder syntax (`${...}`).
573+
574+
If you need to modularize the source of properties used for the replacement, you should
575+
not create multiple properties placeholders. Rather, each module should contribute a
576+
`PropertySource` to the `Environment`. Alternatively, you can create your own
577+
`PropertySourcesPlaceholderConfigurer` bean that gathers the properties to use.
578+
=====
568579

569580
[[xsd-schemas-context-ac]]
570581
=== Using `<annotation-config/>`

framework-docs/modules/ROOT/pages/core/beans/factory-extension.adoc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,17 @@ The `PropertySourcesPlaceholderConfigurer` not only looks for properties in the
372372
file you specify. By default, if it cannot find a property in the specified properties files,
373373
it checks against Spring `Environment` properties and regular Java `System` properties.
374374

375+
[WARNING]
376+
=====
377+
Only one such element should be defined for a given application with the properties
378+
that it needs. Several property placeholders can be configured as long as they have distinct
379+
placeholder syntax (`${...}`).
380+
381+
If you need to modularize the source of properties used for the replacement, you should
382+
not create multiple properties placeholders. Rather, you should create your own
383+
`PropertySourcesPlaceholderConfigurer` bean that gathers the properties to use.
384+
=====
385+
375386
[TIP]
376387
=====
377388
You can use the `PropertySourcesPlaceholderConfigurer` to substitute class names, which

0 commit comments

Comments
 (0)