diff --git a/spring-boot/src/main/java/org/springframework/boot/bind/PropertySourcesPropertyValues.java b/spring-boot/src/main/java/org/springframework/boot/bind/PropertySourcesPropertyValues.java index b8eed8b8291..3e92db48088 100644 --- a/spring-boot/src/main/java/org/springframework/boot/bind/PropertySourcesPropertyValues.java +++ b/spring-boot/src/main/java/org/springframework/boot/bind/PropertySourcesPropertyValues.java @@ -55,7 +55,13 @@ public class PropertySourcesPropertyValues implements PropertyValues { EnumerablePropertySource enumerable = (EnumerablePropertySource) source; if (enumerable.getPropertyNames().length > 0) { for (String propertyName : enumerable.getPropertyNames()) { - Object value = resolver.getProperty(propertyName); + Object value = source.getProperty(propertyName); + try { + value = resolver.getProperty(propertyName); + } + catch (RuntimeException e) { + // Probably could not resolve placeholders, ignore it here + } this.propertyValues.put(propertyName, new PropertyValue( propertyName, value)); } diff --git a/spring-boot/src/test/java/org/springframework/boot/bind/PropertySourcesPropertyValuesTests.java b/spring-boot/src/test/java/org/springframework/boot/bind/PropertySourcesPropertyValuesTests.java index 2a183c70082..c8bb7153f59 100644 --- a/spring-boot/src/test/java/org/springframework/boot/bind/PropertySourcesPropertyValuesTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/bind/PropertySourcesPropertyValuesTests.java @@ -90,6 +90,16 @@ public class PropertySourcesPropertyValuesTests { assertEquals("bar", target.getName()); } + @Test + public void testPlaceholdersBindingWithError() { + TestBean target = new TestBean(); + DataBinder binder = new DataBinder(target); + this.propertySources.addFirst(new MapPropertySource("another", Collections + . singletonMap("something", "${nonexistent}"))); + binder.bind(new PropertySourcesPropertyValues(this.propertySources)); + assertEquals("bar", target.getName()); + } + public static class TestBean { private String name;