========= My application.yml config ===============
========= My defined ConfigurationProperties =========
========= Actual data =========================
========================================== I expect data 'option.input.rules' is an array, but it's map
Comment From: wilkinsona
Unfortunately, as you haven't provided any type information in your configuration properties class, it's difficult for the binder to know what to do. The fact that it's a list in YAML is lost (somewhat) as the information is turned into properties when it's added to the environment. Have you considered using something more strongly typed than Map<String, Object> for input and output?
Comment From: graceyu-own
Unfortunately, as you haven't provided any type information in your configuration properties class, it's difficult for the binder to know what to do. The fact that it's a list in YAML is lost (somewhat) as the information is turned into properties when it's added to the environment. Have you considered using something more strongly typed than
Map<String, Object>forinputandoutput?
Really, if the actual data type is used, this problem can be solved. but i can't do this in real situations. I have many components, their input data types are different (contains key and value), such as:
A component:
B component:
And there may be problems that components have the same key and different types, so i can only use Map<String, Object>
Comment From: wilkinsona
And there may be problems that components have the same key and different types
Configuration properties are intended to be type-safe so they are not the right tool to use for this sort of configuration data. You may be able to write some code of your own using the Binder API that understands the structure of your configuration data and when a particular key will have one type and when it will have another.