diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java index 1329c7a043ac..c33b2ae92e7c 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java @@ -62,7 +62,10 @@ protected Object bindAggregate(ConfigurationPropertyName name, Bindable targe ConfigurationProperty property = source.getConfigurationProperty(name); if (property != null && !hasDescendants) { getContext().setConfigurationProperty(property); - return getContext().getConverter().convert(property.getValue(), target); + Object result = property.getValue(); + result = getContext().getPlaceholdersResolver().resolvePlaceholders(result); + result = getContext().getConverter().convert(result, target); + return result; } source = source.filter(name::isAncestorOf); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/MapBinderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/MapBinderTests.java index cb03bcebc451..1bbcebf94e18 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/MapBinderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/MapBinderTests.java @@ -610,6 +610,19 @@ void bindToMapWithWildcardShouldConvertToTheRightType() { .containsExactly("127.0.0.1", "127.0.0.2"); } + @Test + void bindToMapWithPlaceholdersShouldResolve() { + DefaultConversionService conversionService = new DefaultConversionService(); + conversionService.addConverter(new MapConverter()); + StandardEnvironment environment = new StandardEnvironment(); + Binder binder = new Binder(this.sources, new PropertySourcesPlaceholdersResolver(environment), conversionService, null, null); + TestPropertySourceUtils.addInlinedPropertiesToEnvironment(environment, "bar=bc"); + this.sources.add(new MockConfigurationPropertySource("foo", "a${bar},${bar}d")); + Map map = binder.bind("foo", STRING_STRING_MAP).get(); + assertThat(map).containsKey("abc"); + assertThat(map).containsKey("bcd"); + } + private Bindable> getMapBindable(Class keyGeneric, ResolvableType valueType) { ResolvableType keyType = ResolvableType.forClass(keyGeneric); return Bindable.of(ResolvableType.forClassWithGenerics(Map.class, keyType, valueType));