public class ProfileAwarePropertySource extends Object implements org.springframework.core.Ordered
Holder for a folder of properties resources comprised of something like the following on the classpath:
Where the [environment] is a key that is resolved from the current Spring profile. Given that set of properties, they get ordered in the following way:
If you are using Spring boot, this is a deprecated construct and instead you should rely on application.properties and the profile-specific variants of that. Registration
is the same as FrameworkCommonPropertySource.
Properties registered via this ProfileAwarePropertySource is functionally equivalent to registering them via PropertySource and have the same ordering
semantics as
"@PropertySource annotations on your @Configuration classes.
The exception is that these are also guaranteed to take a higher precedence than FrameworkCommonPropertySource.
There is generally only a single one of these beans registered in the application. If multiple of them are registered, they are ordered based on
getOrder() and all properties are added to the Environment prior to moving to the next ProfileAwarePropertySource.
These are guaranteed to take a higher precedence (and thus override) properties registered via FrameworkCommonPropertySource
These bean instances are created very early in the Spring lifecycle, during BeanFactoryPostProcessor instantiation. Therefore
you should not be doing any complicated bean logic here (instantating dependencies, trying to @Autowire anything, etc) or
else you might run into unintended consequences.
ProfileAwarePropertiesBeanFactoryPostProcessor}| Modifier and Type | Field and Description |
|---|---|
protected String |
classpathFolder |
static int |
DEFAULT_ORDER |
protected int |
order |
| Constructor and Description |
|---|
ProfileAwarePropertySource(String classpathFolder) |
ProfileAwarePropertySource(String classpathFolder,
int order) |
| Modifier and Type | Method and Description |
|---|---|
String |
getClasspathFolder() |
int |
getOrder()
Semantics of this ordering are slightly different than others.
|
public static final int DEFAULT_ORDER
protected String classpathFolder
protected int order
public ProfileAwarePropertySource(String classpathFolder)
public ProfileAwarePropertySource(String classpathFolder, int order)
public String getClasspathFolder()
public int getOrder()
ProfileAwarePropertiesBeanFactoryPostProcessor which means
that it has a higher resolution precedence.getOrder in interface org.springframework.core.OrderedCopyright © 2017. All rights reserved.