diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java index 3c238fc0285..1b0176655f2 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java @@ -454,7 +454,8 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor, } } throw new IllegalStateException("File extension of config file location '" + location - + "' is not known to any PropertySourceLoader"); + + "' is not known to any PropertySourceLoader. If the location is meant to reference " + + "a directory, it must end in '/'"); } Set processed = new HashSet<>(); for (PropertySourceLoader loader : this.propertySourceLoaders) { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java index 2c13674ad94..3abec00e2ed 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java @@ -989,7 +989,16 @@ class ConfigFileApplicationListenerTests { "spring.config.location=" + location); assertThatIllegalStateException() .isThrownBy(() -> this.initializer.postProcessEnvironment(this.environment, this.application)) - .withMessageContaining(location); + .withMessageContaining(location) + .withMessageContaining("If the location is meant to reference a directory, it must end in '/'"); + } + + @Test + void whenConfigLocationSpecifiesFolderConfigFileProcessingContinues() { + String location = "classpath:application.unknown/"; + TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.environment, + "spring.config.location=" + location); + this.initializer.postProcessEnvironment(this.environment, this.application); } private Condition matchingPropertySource(final String sourceName) {