Skip to content

Commit

Permalink
doc(howTo.application.customizeEnvironmentOrApplicationContext): add …
Browse files Browse the repository at this point in the history
…notes
  • Loading branch information
alfredo-toledano committed Jul 6, 2024
1 parent 8a3f73a commit 5d721d2
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,17 @@ public class MyEnvironmentPostProcessor implements EnvironmentPostProcessor {

@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
Resource path = new ClassPathResource("com/example/myapp/config.yml");
Resource path = new ClassPathResource("com/example/myapp/config.yml"); // TODO: Where is this file defined?
PropertySource<?> propertySource = loadYaml(path);
// Spring Boot loads -- usual property sources in the -- Environment
environment.getPropertySources().addLast(propertySource);
}

/**
* Adds the `custom-resource` property source at the end of the list -> others take precedence
* @param path
* @return
*/
private PropertySource<?> loadYaml(Resource path) {
Assert.isTrue(path.exists(), () -> "Resource " + path + " does not exist");
try {
Expand Down

0 comments on commit 5d721d2

Please sign in to comment.