Loads the default configuration for application names prefixed with (#2262)

This commit is contained in:
Kaveh Shamsi
2023-05-03 19:33:14 +02:00
committed by GitHub
parent 4c93ad7e75
commit 5a1797ac47
3 changed files with 11 additions and 1 deletions

View File

@@ -219,7 +219,7 @@ public class NativeEnvironmentRepository implements EnvironmentRepository, Searc
Map<String, Object> map = new HashMap<>();
map.put("spring.profiles.active", profile);
String config = application;
if (!config.startsWith("application")) {
if (!config.equals("application")) {
config = "application," + config;
}
map.put("spring.config.name", config);

View File

@@ -191,6 +191,15 @@ public class NativeEnvironmentRepositoryTests {
assertThat(environment.getPropertySources().get(0).getSource().get("foo")).isEqualTo("app");
}
@Test
public void placeholdersApplicationWithPrefixAndProfile() {
this.repository.setSearchLocations("classpath:/test/{profile}/{application}/");
// gh-2259 application name starts with "application"
Environment environment = this.repository.findOne("applicationxyz", "dev", "master");
assertThat(environment.getPropertySources().size()).isEqualTo(1);
assertThat(environment.getPropertySources().get(0).getSource().get("foo")).isEqualTo("default-app");
}
@Test
public void locationPlaceholdersApplication() {
this.repository.setSearchLocations("classpath:/test/{application}");