Top Description Fields Constructors Methods
org.springframework.core

public final Class SpringProperties

extends Object
Class Inheritance
Imports
java.io.IOException, .InputStream, java.net.URL, java.util.Properties, org.springframework.lang.Nullable

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. When checking a property, local entries are being checked first, then falling back to JVM-level system properties through a System#getProperty 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 (e.g. WebSphere). See setFlag for a convenient way to locally set such flags to "true".

Author
Juergen Hoeller
Since
3.2.7
See Also
org.springframework.beans.StandardBeanInfoFactory#IGNORE_BEANINFO_PROPERTY_NAME, org.springframework.core.env.AbstractEnvironment#IGNORE_GETENV_PROPERTY_NAME, org.springframework.expression.spel.SpelParserConfiguration#SPRING_EXPRESSION_COMPILER_MODE_PROPERTY_NAME, org.springframework.jdbc.core.StatementCreatorUtils#IGNORE_GETPARAMETERTYPE_PROPERTY_NAME, org.springframework.jndi.JndiLocatorDelegate#IGNORE_JNDI_PROPERTY_NAME, org.springframework.objenesis.SpringObjenesis#IGNORE_OBJENESIS_PROPERTY_NAME, org.springframework.test.context.NestedTestConfiguration#ENCLOSING_CONFIGURATION_PROPERTY_NAME, org.springframework.test.context.TestConstructor#TEST_CONSTRUCTOR_AUTOWIRE_MODE_PROPERTY_NAME, org.springframework.test.context.cache.ContextCache#MAX_CONTEXT_CACHE_SIZE_PROPERTY_NAME

Field Summary

Modifier and TypeField and Description
private static final Properties
private static final String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

true if the property is set to "true", false otherwise
getFlag
(String
the property key
key
)

Retrieve the flag for the given property key.

public static String

Returns:

the associated property value, or null if none found
getProperty
(String
the property key
key
)

Retrieve the property value for the given key, checking local Spring properties first and falling back to JVM-level system properties.

public static void
setFlag(String
the property key
key
)

Programmatically set a local flag to "true", overriding an entry in the spring.properties file (if any).

public static void
setProperty(String
the property key
key
,
String
the associated property value, or null to reset it
value
)

Programmatically set a local property, overriding an entry in the spring.properties file (if any).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

localPropertiesback to summary
private static final Properties localProperties
PROPERTIES_RESOURCE_LOCATIONback to summary
private static final String PROPERTIES_RESOURCE_LOCATION

Constructor Detail

SpringPropertiesback to summary
private SpringProperties()

Method Detail

getFlagback to summary
public static boolean getFlag(String key)

Retrieve the flag for the given property key.

Parameters
key:String

the property key

Returns:boolean

true if the property is set to "true", false otherwise

getPropertyback to summary
public static String getProperty(String key)

Retrieve the property value for the given key, checking local Spring properties first and falling back to JVM-level system properties.

Parameters
key:String

the property key

Returns:String

the associated property value, or null if none found

Annotations
@Nullable
setFlagback to summary
public static void setFlag(String key)

Programmatically set a local flag to "true", overriding an entry in the spring.properties file (if any).

Parameters
key:String

the property key

setPropertyback to summary
public static void setProperty(String key, String value)

Programmatically set a local property, overriding an entry in the spring.properties file (if any).

Parameters
key:String

the property key

value:String

the associated property value, or null to reset it