'Read config yaml as map of list of Map using Value annotation/SPEL in SpringBoot

I am trying to construct Map<String, List<Map<String, String>>> by reading the configs from yaml file.

My configs look like :

company: '{
      "employee": [
        {
          "key1": "value1",
          "key2", "value2"
        },
        {
          "key1": "key1",
          "key2", "value2"
        }
      ]
}'

I am trying to read it using @Value annotation

@Value("#{${company}}")
public Map<String, List<Map<String, String>>> companyEmployeeMap;

I get an error :

EL1043E: Unexpected token. Expected 'rsquare(])' but was 'comma(,)'

I have checked the json a couple of times and it is formatted correctly. Is there something I am missing here while working with complex types in SPEL?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source