Top Description Fields Constructors Methods
org.springframework.core.env

public Class StandardEnvironment

extends AbstractEnvironment
Class Inheritance

Environment implementation suitable for use in 'standard' (i.e. non-web) applications.

In addition to the usual functions of a ConfigurableEnvironment such as property resolution and profile-related operations, this implementation configures two default property sources, to be searched in the following order:

That is, if the key "xyz" is present both in the JVM system properties as well as in the set of environment variables for the current process, the value of key "xyz" from system properties will return from a call to environment.getProperty("xyz"). This ordering is chosen by default because system properties are per-JVM, while environment variables may be the same across many JVMs on a given system. Giving system properties precedence allows for overriding of environment variables on a per-JVM basis.

These default property sources may be removed, reordered, or replaced; and additional property sources may be added using the MutablePropertySources instance available from getPropertySources(). See ConfigurableEnvironment Javadoc for usage examples.

See SystemEnvironmentPropertySource javadoc for details on special handling of property names in shell environments (e.g. Bash) that disallow period characters in variable names.

Authors
Chris Beams, Phillip Webb
Since
3.1
See Also
ConfigurableEnvironment, SystemEnvironmentPropertySource, org.springframework.web.context.support.StandardServletEnvironment

Field Summary

Modifier and TypeField and Description
public static final String
SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME

System environment property source name: systemEnvironment.

public static final String
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME

JVM system properties property source name: systemProperties.

Inherited from org.springframework.core.env.AbstractEnvironment:
ACTIVE_PROFILES_PROPERTY_NAMEDEFAULT_PROFILES_PROPERTY_NAMEIGNORE_GETENV_PROPERTY_NAMEloggerRESERVED_DEFAULT_PROFILE_NAME

Constructor Summary

AccessConstructor and Description
public
StandardEnvironment()

Create a new StandardEnvironment instance with a default MutablePropertySources instance.

protected
StandardEnvironment(MutablePropertySources
property sources to use
propertySources
)

Create a new StandardEnvironment instance with a specific MutablePropertySources instance.

Method Summary

Modifier and TypeMethod and Description
protected void
customizePropertySources(MutablePropertySources propertySources)

Overrides org.springframework.core.env.AbstractEnvironment.customizePropertySources.

Customize the set of property sources with those appropriate for any standard Java environment:
  • systemProperties
  • systemEnvironment
Inherited from org.springframework.core.env.AbstractEnvironment:
acceptsProfilesacceptsProfilesaddActiveProfilecontainsPropertycreatePropertyResolverdoGetActiveProfilesdoGetActiveProfilesPropertydoGetDefaultProfilesdoGetDefaultProfilesPropertygetActiveProfilesgetConversionServicegetDefaultProfilesgetPropertygetPropertygetPropertygetPropertygetPropertyResolvergetPropertySourcesgetRequiredPropertygetRequiredPropertygetReservedDefaultProfilesgetSystemEnvironmentgetSystemPropertiesisProfileActivemergeresolvePlaceholdersresolveRequiredPlaceholderssetActiveProfilessetConversionServicesetDefaultProfilessetIgnoreUnresolvableNestedPlaceholderssetPlaceholderPrefixsetPlaceholderSuffixsetRequiredPropertiessetValueSeparatorsuppressGetenvAccesstoStringvalidateProfilevalidateRequiredProperties

Field Detail

SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAMEback to summary
public static final String SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME

System environment property source name: systemEnvironment.

SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAMEback to summary
public static final String SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME

JVM system properties property source name: systemProperties.

Constructor Detail

StandardEnvironmentback to summary
public StandardEnvironment()

Create a new StandardEnvironment instance with a default MutablePropertySources instance.

StandardEnvironmentback to summary
protected StandardEnvironment(MutablePropertySources propertySources)

Create a new StandardEnvironment instance with a specific MutablePropertySources instance.

Parameters
propertySources:MutablePropertySources

property sources to use

Since
5.3.4

Method Detail

customizePropertySourcesback to summary
protected void customizePropertySources(MutablePropertySources propertySources)

Overrides org.springframework.core.env.AbstractEnvironment.customizePropertySources.

Customize the set of property sources with those appropriate for any standard Java environment:

  • systemProperties
  • systemEnvironment

Properties present in systemProperties will take precedence over those in systemEnvironment.

Annotations
@Override
See Also
AbstractEnvironment#customizePropertySources(MutablePropertySources), getSystemProperties(), getSystemEnvironment()