diff --git a/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java b/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java index f2a1bc6aa6..1c256fb44b 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java @@ -96,8 +96,8 @@ public class ConfigFileApplicationListener implements private static final String CONFIG_LOCATION_PROPERTY = "spring.config.location"; - private static final String DEFAULT_SEARCH_LOCATIONS = "file:./,file:./config/," - + "classpath:/,classpath:/config/"; + private static final String DEFAULT_SEARCH_LOCATIONS = "file:./config/,file:./," + + "classpath:/config/,classpath:/"; private static final String DEFAULT_NAMES = "application"; diff --git a/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java b/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java index a36ff18879..6a8aefa6ea 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java @@ -133,6 +133,15 @@ public class ConfigFileApplicationListenerTests { } } + @Test + public void moreSpecificLocationTakesPrecedenceOverRoot() throws Exception { + EnvironmentTestUtils.addEnvironment(this.environment, + "spring.config.name:specific"); + this.initializer.onApplicationEvent(this.event); + String property = this.environment.getProperty("my.property"); + assertThat(property, equalTo("specific")); + } + @Test public void loadTwoOfThreePropertiesFile() throws Exception { EnvironmentTestUtils.addEnvironment(this.environment, "spring.config.location:" diff --git a/spring-boot/src/test/resources/config/specific.properties b/spring-boot/src/test/resources/config/specific.properties new file mode 100644 index 0000000000..6a108f2dcd --- /dev/null +++ b/spring-boot/src/test/resources/config/specific.properties @@ -0,0 +1 @@ +my.property=specific \ No newline at end of file diff --git a/spring-boot/src/test/resources/specific.properties b/spring-boot/src/test/resources/specific.properties new file mode 100644 index 0000000000..85fab4f45e --- /dev/null +++ b/spring-boot/src/test/resources/specific.properties @@ -0,0 +1 @@ +my.property=root \ No newline at end of file