Skip to content

Commit

Permalink
Adjust the priority of the configs
Browse files Browse the repository at this point in the history
  • Loading branch information
woshikid committed Jan 12, 2023
1 parent 9e9eb71 commit 4d0c516
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public List<Context> generateAutomaticContexts(List<String> profiles, boolean re

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

StringBuilder baseContext = new StringBuilder(root);
if (!properties.getName().startsWith("/")) {
Expand All @@ -58,6 +57,9 @@ public List<Context> generateAutomaticContexts(List<String> profiles, boolean re
// getName() defaults to ${spring.application.name} or application
baseContext.append(properties.getName());
contexts.add(new Context(baseContext.toString()));

// profiles have a higher priority, should be added at the end
addProfiles(contexts, defaultContext, profiles);
addProfiles(contexts, baseContext.toString(), profiles);

if (reverse) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ public void compositePropertySourceHoldsPropertySourcesInCorrectOrder() {

assertThat(propertySources.get(0).getName())
.endsWith(someName + properties.getProfileSeparator() + someProfile);
assertThat(propertySources.get(1).getName()).endsWith(someName);
assertThat(propertySources.get(2).getName()).endsWith(
assertThat(propertySources.get(1).getName()).endsWith(
defaultContext + properties.getProfileSeparator() + someProfile);
assertThat(propertySources.get(2).getName()).endsWith(someName);
assertThat(propertySources.get(3).getName()).endsWith(defaultContext);
}

Expand Down

0 comments on commit 4d0c516

Please sign in to comment.