========= My application.yml config =============== SpringBoot @ConfigurationProperties nested map exists inject type mismatch.

========= My defined ConfigurationProperties ========= SpringBoot @ConfigurationProperties nested map exists inject type mismatch.

========= Actual data ========================= SpringBoot @ConfigurationProperties nested map exists inject type mismatch.

========================================== 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> for input and output?

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: SpringBoot @ConfigurationProperties nested map exists inject type mismatch.

B component: SpringBoot @ConfigurationProperties nested map exists inject type mismatch.

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.