-
Notifications
You must be signed in to change notification settings - Fork 41.3k
Description
The docs currently say:
A nice way to augment and modify this ordering is to add
@PropertySource
annotations to your application sources. Classes passed to theSpringApplication
static convenience methods and those added usingsetSources(
) are inspected to see if they have@PropertySource
s. If they do, those properties are added to theEnvironment
early enough to be used in all phases of theApplicationContext
lifecycle.
And:
While using
@PropertySource
on your@SpringBootApplication
may seem to be a convenient and easy way to load a custom resource in theEnvironment
, we do not recommend it, because Spring Boot prepares theEnvironment
before theApplicationContext
is refreshed. Any key defined with@PropertySource
is loaded too late to have any effect on auto-configuration.
The former is recommending what the latter says is not recommended.