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());
|
metadata.getAnnotationAttributes(org.springframework.context.annotation.PropertySource.class.getName());
|
||||||
if (propertySourceAttributes != null) {
|
if (propertySourceAttributes != null) {
|
||||||
String name = (String) propertySourceAttributes.get("name");
|
String name = (String) propertySourceAttributes.get("name");
|
||||||
String location = (String) propertySourceAttributes.get("value");
|
String[] locations = (String[]) propertySourceAttributes.get("value");
|
||||||
ClassLoader classLoader = this.resourceLoader.getClassLoader();
|
ClassLoader classLoader = this.resourceLoader.getClassLoader();
|
||||||
ResourcePropertySource ps = StringUtils.hasText(name) ?
|
for (String location : locations) {
|
||||||
new ResourcePropertySource(name, location, classLoader) :
|
ResourcePropertySource ps = StringUtils.hasText(name) ?
|
||||||
new ResourcePropertySource(location, classLoader);
|
new ResourcePropertySource(name, location, classLoader) :
|
||||||
this.propertySources.push(ps);
|
new ResourcePropertySource(location, classLoader);
|
||||||
|
this.propertySources.push(ps);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// process any @ComponentScan annotions
|
// process any @ComponentScan annotions
|
||||||
|
|
|
||||||
|
|
@ -117,12 +117,14 @@ public @interface PropertySource {
|
||||||
String name() default "";
|
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
|
* For example, {@code "classpath:/com/myco/app.properties"} or
|
||||||
* {@code "file:/path/to/file"}. Note that resource location wildcards
|
* {@code "file:/path/to/file"}. Note that resource location wildcards
|
||||||
* are not permitted, and that a location must evaluate to exactly one
|
* are not permitted, and that each location must evaluate to exactly one
|
||||||
* {@code .properties} resource.
|
* {@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