Merge branch '3.1.x'

This commit is contained in:
Ryan Baxter
2023-05-03 14:14:31 -04:00
3 changed files with 11 additions and 1 deletions

View File

@@ -225,7 +225,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

@@ -193,6 +193,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}");