- 
                Notifications
    You must be signed in to change notification settings 
- Fork 41.6k
Closed
Description
Hello,
after migrated from Spring Boot 1.5.3.RELEASE to 2.1.3.RELEASE we've encountered a bug(?) with property binding.
The example code can be found here. It's a simple application with one property class that receives values from the application.yml via the @ConfigurationProperties annotation.
Starting the DemoApplication works fine.
But starting the simple DemoApplicationTests does not work, as the demo uses "test" profile and therefore the property class receives it's values from "application-test.yml".
The excepton does NOT occur if "ignoreUnknownFields" is NOT present (i.e., set to true).
Caused by: org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'demo-properties' to com.example.demo.DemoApplication$DemoProperties
	at org.springframework.boot.context.properties.bind.Binder.handleBindError(Binder.java:249) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
	at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:225) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
	at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:208) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
	at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:190) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
	at org.springframework.boot.context.properties.ConfigurationPropertiesBinder.bind(ConfigurationPropertiesBinder.java:83) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
	at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.bind(ConfigurationPropertiesBindingPostProcessor.java:107) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
	... 43 common frames omitted
Caused by: org.springframework.boot.context.properties.bind.UnboundConfigurationPropertiesException: The elements [demo-properties.data[2]] were left unbound.
	at org.springframework.boot.context.properties.bind.handler.NoUnboundElementsBindHandler.checkNoUnboundElements(NoUnboundElementsBindHandler.java:88) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
	at org.springframework.boot.context.properties.bind.handler.NoUnboundElementsBindHandler.onFinish(NoUnboundElementsBindHandler.java:73) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
	at org.springframework.boot.context.properties.bind.Binder.handleBindResult(Binder.java:235) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
	at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:222) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
	... 47 common frames omitted
The bug does only appear when the list in application-test.yml is SMALLER than the list in application.yml.
Regards,
Manuel
anatoliy-balakirev and nanachimi
Metadata
Metadata
Assignees
Labels
type: bugA general bugA general bug