This commit is contained in:
Phillip Webb
2017-07-06 16:52:53 -07:00
parent 222a09cfd3
commit aa57ca7e18
26 changed files with 191 additions and 173 deletions

View File

@@ -32,11 +32,9 @@ import org.springframework.core.io.Resource;
* @author Stephane Nicoll
*/
// tag::example[]
public class EnvironmentPostProcessorExample
implements EnvironmentPostProcessor {
public class EnvironmentPostProcessorExample implements EnvironmentPostProcessor {
private final YamlPropertySourceLoader loader
= new YamlPropertySourceLoader();
private final YamlPropertySourceLoader loader = new YamlPropertySourceLoader();
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment,
@@ -48,15 +46,14 @@ public class EnvironmentPostProcessorExample
private PropertySource<?> loadYaml(Resource path) {
if (!path.exists()) {
throw new IllegalArgumentException("Resource " + path
+ " does not exist");
throw new IllegalArgumentException("Resource " + path + " does not exist");
}
try {
return this.loader.load("custom-resource", path, null);
}
catch (IOException ex) {
throw new IllegalStateException("Failed to load yaml configuration "
+ "from " + path, ex);
throw new IllegalStateException(
"Failed to load yaml configuration from " + path, ex);
}
}