|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2012 the original author or authors. |
|
|
|
* Copyright 2002-2016 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -35,24 +35,24 @@ import java.util.Map; |
|
|
|
* |
|
|
|
* |
|
|
|
* <h4>Example: adding a new property source with highest search priority</h4> |
|
|
|
* <h4>Example: adding a new property source with highest search priority</h4> |
|
|
|
* <pre class="code"> |
|
|
|
* <pre class="code"> |
|
|
|
* ConfigurableEnvironment environment = new StandardEnvironment(); |
|
|
|
* ConfigurableEnvironment environment = new StandardEnvironment(); |
|
|
|
* MutablePropertySources propertySources = environment.getPropertySources(); |
|
|
|
* MutablePropertySources propertySources = environment.getPropertySources(); |
|
|
|
* Map<String, String> myMap = new HashMap<String, String>(); |
|
|
|
* Map<String, String> myMap = new HashMap<String, String>(); |
|
|
|
* myMap.put("xyz", "myValue"); |
|
|
|
* myMap.put("xyz", "myValue"); |
|
|
|
* propertySources.addFirst(new MapPropertySource("MY_MAP", myMap)); |
|
|
|
* propertySources.addFirst(new MapPropertySource("MY_MAP", myMap)); |
|
|
|
* </pre> |
|
|
|
* </pre> |
|
|
|
* |
|
|
|
* |
|
|
|
* <h4>Example: removing the default system properties property source</h4> |
|
|
|
* <h4>Example: removing the default system properties property source</h4> |
|
|
|
* <pre class="code"> |
|
|
|
* <pre class="code"> |
|
|
|
* MutablePropertySources propertySources = environment.getPropertySources(); |
|
|
|
* MutablePropertySources propertySources = environment.getPropertySources(); |
|
|
|
* propertySources.remove(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME) |
|
|
|
* propertySources.remove(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME) |
|
|
|
* </pre> |
|
|
|
* </pre> |
|
|
|
* |
|
|
|
* |
|
|
|
* <h4>Example: mocking the system environment for testing purposes</h4> |
|
|
|
* <h4>Example: mocking the system environment for testing purposes</h4> |
|
|
|
* <pre class="code"> |
|
|
|
* <pre class="code"> |
|
|
|
* MutablePropertySources propertySources = environment.getPropertySources(); |
|
|
|
* MutablePropertySources propertySources = environment.getPropertySources(); |
|
|
|
* MockPropertySource mockEnvVars = new MockPropertySource().withProperty("xyz", "myValue"); |
|
|
|
* MockPropertySource mockEnvVars = new MockPropertySource().withProperty("xyz", "myValue"); |
|
|
|
* propertySources.replace(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, mockEnvVars); |
|
|
|
* propertySources.replace(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, mockEnvVars); |
|
|
|
* </pre> |
|
|
|
* </pre> |
|
|
|
* |
|
|
|
* |
|
|
|
* When an {@link Environment} is being used by an {@code ApplicationContext}, it is |
|
|
|
* When an {@link Environment} is being used by an {@code ApplicationContext}, it is |
|
|
|
@ -64,7 +64,6 @@ import java.util.Map; |
|
|
|
* org.springframework.context.support.PropertySourcesPlaceholderConfigurer property |
|
|
|
* org.springframework.context.support.PropertySourcesPlaceholderConfigurer property |
|
|
|
* placeholder configurers}. |
|
|
|
* placeholder configurers}. |
|
|
|
* |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @author Chris Beams |
|
|
|
* @author Chris Beams |
|
|
|
* @since 3.1 |
|
|
|
* @since 3.1 |
|
|
|
* @see StandardEnvironment |
|
|
|
* @see StandardEnvironment |
|
|
|
|