Allow multiple locations via @PropertySource#value
Issue: SPR-8314
This commit is contained in:
parent
0756a6abfe
commit
2ceeff370a
|
|
@ -174,12 +174,14 @@ class ConfigurationClassParser {
|
|||
metadata.getAnnotationAttributes(org.springframework.context.annotation.PropertySource.class.getName());
|
||||
if (propertySourceAttributes != null) {
|
||||
String name = (String) propertySourceAttributes.get("name");
|
||||
String location = (String) propertySourceAttributes.get("value");
|
||||
String[] locations = (String[]) propertySourceAttributes.get("value");
|
||||
ClassLoader classLoader = this.resourceLoader.getClassLoader();
|
||||
ResourcePropertySource ps = StringUtils.hasText(name) ?
|
||||
new ResourcePropertySource(name, location, classLoader) :
|
||||
new ResourcePropertySource(location, classLoader);
|
||||
this.propertySources.push(ps);
|
||||
for (String location : locations) {
|
||||
ResourcePropertySource ps = StringUtils.hasText(name) ?
|
||||
new ResourcePropertySource(name, location, classLoader) :
|
||||
new ResourcePropertySource(location, classLoader);
|
||||
this.propertySources.push(ps);
|
||||
}
|
||||
}
|
||||
|
||||
// process any @ComponentScan annotions
|
||||
|
|
|
|||
|
|
@ -117,12 +117,14 @@ public @interface PropertySource {
|
|||
String name() default "";
|
||||
|
||||
/**
|
||||
* Indicate the resource location of the properties file to be loaded.
|
||||
* Indicate the resource location(s) of the properties file to be loaded.
|
||||
* For example, {@code "classpath:/com/myco/app.properties"} or
|
||||
* {@code "file:/path/to/file"}. Note that resource location wildcards
|
||||
* are not permitted, and that a location must evaluate to exactly one
|
||||
* {@code .properties} resource.
|
||||
* are not permitted, and that each location must evaluate to exactly one
|
||||
* {@code .properties} resource. Each location will be added to the
|
||||
* enclosing {@code Environment} as its own property source, and in the order
|
||||
* declared.
|
||||
*/
|
||||
String value();
|
||||
String[] value();
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue