Class ResourcePropertySource
java.lang.Object
org.springframework.core.env.PropertySource<T>
org.springframework.core.env.EnumerablePropertySource<Map<String,Object>>
org.springframework.core.env.MapPropertySource
org.springframework.core.env.PropertiesPropertySource
org.springframework.core.io.support.ResourcePropertySource
Subclass of
PropertiesPropertySource
that loads a Properties
object
from a given Resource
or resource location such as
"classpath:/com/myco/foo.properties"
or "file:/path/to/file.xml"
.
Both traditional and XML-based properties file formats are supported; however, in
order for XML processing to take effect, the underlying Resource
's
getFilename()
method must
return a non-null
value that ends in ".xml"
.
- Since:
- 3.1
- Author:
- Chris Beams, Juergen Hoeller
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.core.env.PropertySource
PropertySource.StubPropertySource
-
Field Summary
Fields inherited from class org.springframework.core.env.PropertySource
logger, name, source
-
Constructor Summary
ConstructorDescriptionResourcePropertySource
(String location) Create a PropertySource based on Properties loaded from the given resource location.ResourcePropertySource
(String location, ClassLoader classLoader) Create a PropertySource based on Properties loaded from the given resource location and use the given class loader to load the resource, assuming it is prefixed withclasspath:
.ResourcePropertySource
(String name, String location) Create a PropertySource having the given name based on Properties loaded from the given resource location.ResourcePropertySource
(String name, String location, ClassLoader classLoader) Create a PropertySource having the given name based on Properties loaded from the given resource location and using the given class loader to load the resource (assuming it is prefixed withclasspath:
).ResourcePropertySource
(String name, Resource resource) Create a PropertySource having the given name based on Properties loaded from the given encoded resource.ResourcePropertySource
(String name, EncodedResource resource) Create a PropertySource having the given name based on Properties loaded from the given encoded resource.ResourcePropertySource
(Resource resource) Create a PropertySource based on Properties loaded from the given resource.ResourcePropertySource
(EncodedResource resource) Create a PropertySource based on Properties loaded from the given resource. -
Method Summary
Modifier and TypeMethodDescriptionReturn a potentially adapted variant of thisResourcePropertySource
, overriding the previously given (or derived) name with the specified name.Return a potentially adapted variant of thisResourcePropertySource
, overriding the previously given name (if any) with the original resource name (equivalent to the name generated by the name-less constructor variants).Methods inherited from class org.springframework.core.env.PropertiesPropertySource
getPropertyNames
Methods inherited from class org.springframework.core.env.MapPropertySource
containsProperty, getProperty
-
Constructor Details
-
ResourcePropertySource
Create a PropertySource having the given name based on Properties loaded from the given encoded resource.- Throws:
IOException
-
ResourcePropertySource
Create a PropertySource based on Properties loaded from the given resource. The name of the PropertySource will be generated based on thedescription
of the given resource.- Throws:
IOException
-
ResourcePropertySource
Create a PropertySource having the given name based on Properties loaded from the given encoded resource.- Throws:
IOException
-
ResourcePropertySource
Create a PropertySource based on Properties loaded from the given resource. The name of the PropertySource will be generated based on thedescription
of the given resource.- Throws:
IOException
-
ResourcePropertySource
public ResourcePropertySource(String name, String location, ClassLoader classLoader) throws IOException Create a PropertySource having the given name based on Properties loaded from the given resource location and using the given class loader to load the resource (assuming it is prefixed withclasspath:
).- Throws:
IOException
-
ResourcePropertySource
Create a PropertySource based on Properties loaded from the given resource location and use the given class loader to load the resource, assuming it is prefixed withclasspath:
. The name of the PropertySource will be generated based on thedescription
of the resource.- Throws:
IOException
-
ResourcePropertySource
Create a PropertySource having the given name based on Properties loaded from the given resource location. The default thread context class loader will be used to load the resource (assuming the location string is prefixed withclasspath:
).- Throws:
IOException
-
ResourcePropertySource
Create a PropertySource based on Properties loaded from the given resource location. The name of the PropertySource will be generated based on thedescription
of the resource.- Throws:
IOException
-
-
Method Details
-
withName
Return a potentially adapted variant of thisResourcePropertySource
, overriding the previously given (or derived) name with the specified name.- Since:
- 4.0.4
-
withResourceName
Return a potentially adapted variant of thisResourcePropertySource
, overriding the previously given name (if any) with the original resource name (equivalent to the name generated by the name-less constructor variants).- Since:
- 4.1
-