Skip to content

Commit d3f317b

Browse files
committed
Adjust the priority of the configs
1 parent 24079d6 commit d3f317b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

spring-cloud-zookeeper-config/src/main/java/org/springframework/cloud/zookeeper/config/ZookeeperPropertySources.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public List<Context> generateAutomaticContexts(List<String> profiles, boolean re
4949

5050
String defaultContext = root + "/" + properties.getDefaultContext();
5151
contexts.add(new Context(defaultContext));
52-
addProfiles(contexts, defaultContext, profiles);
5352

5453
StringBuilder baseContext = new StringBuilder(root);
5554
if (!properties.getName().startsWith("/")) {
@@ -58,6 +57,9 @@ public List<Context> generateAutomaticContexts(List<String> profiles, boolean re
5857
// getName() defaults to ${spring.application.name} or application
5958
baseContext.append(properties.getName());
6059
contexts.add(new Context(baseContext.toString()));
60+
61+
// profiles have a higher priority, should be added at the end
62+
addProfiles(contexts, defaultContext, profiles);
6163
addProfiles(contexts, baseContext.toString(), profiles);
6264

6365
if (reverse) {

spring-cloud-zookeeper-config/src/test/java/org/springframework/cloud/zookeeper/config/ZookeeperPropertySourceLocatorTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@ public void compositePropertySourceHoldsPropertySourcesInCorrectOrder() {
227227

228228
assertThat(propertySources.get(0).getName())
229229
.endsWith(someName + properties.getProfileSeparator() + someProfile);
230-
assertThat(propertySources.get(1).getName()).endsWith(someName);
231-
assertThat(propertySources.get(2).getName()).endsWith(
230+
assertThat(propertySources.get(1).getName()).endsWith(
232231
defaultContext + properties.getProfileSeparator() + someProfile);
232+
assertThat(propertySources.get(2).getName()).endsWith(someName);
233233
assertThat(propertySources.get(3).getName()).endsWith(defaultContext);
234234
}
235235

0 commit comments

Comments
 (0)