Class SpringProperties
java.lang.Object
org.springframework.core.SpringProperties
Static holder for local Spring properties, i.e. defined at the Spring library level.
Reads a spring.properties
file from the root of the Spring library classpath,
and also allows for programmatically setting properties through setProperty(java.lang.String, java.lang.String)
.
When checking a property, local entries are being checked first, then falling back
to JVM-level system properties through a System.getProperty(java.lang.String)
check.
This is an alternative way to set Spring-related system properties such as
"spring.getenv.ignore" and "spring.beaninfo.ignore", in particular for scenarios
where JVM system properties are locked on the target platform (for example, WebSphere).
See setFlag(java.lang.String)
for a convenient way to locally set such flags to "true".
- Since:
- 3.2.7
- Author:
- Juergen Hoeller
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionRetrieve the flag for the given property key, returningnull
instead offalse
in case of no actual flag set.static boolean
Retrieve the flag for the given property key.getProperty
(String key) Retrieve the property value for the given key, checking local Spring properties first and falling back to JVM-level system properties.static void
Programmatically set a local flag to "true", overriding an entry in thespring.properties
file (if any).static void
Programmatically set a local flag to the given value, overriding an entry in thespring.properties
file (if any).static void
setProperty
(String key, @Nullable String value) Programmatically set a local property, overriding an entry in thespring.properties
file (if any).
-
Method Details
-
setProperty
-
getProperty
-
setFlag
Programmatically set a local flag to "true", overriding an entry in thespring.properties
file (if any).- Parameters:
key
- the property key
-
setFlag
Programmatically set a local flag to the given value, overriding an entry in thespring.properties
file (if any).- Parameters:
key
- the property keyvalue
- the associated boolean value- Since:
- 6.2.6
-
getFlag
Retrieve the flag for the given property key.- Parameters:
key
- the property key- Returns:
true
if the property is set to the string "true" (ignoring case),false
otherwise
-
checkFlag
Retrieve the flag for the given property key, returningnull
instead offalse
in case of no actual flag set.- Parameters:
key
- the property key- Returns:
true
if the property is set to the string "true" (ignoring case), false if it is set to any other value,null
if it is not set at all- Since:
- 6.2.6
-