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