0

Please consider my Application.YAML file.

name-change:
  - original-name: mango
    changed-name: mangifera
  - original-name: coconut
    changed-name: cocos 

I want to access this configs in the spring-boot application/ RestController.

@Value("${name-change[0].original-name}")
private String origianlName;

The above code works perfectly fine.

But failed to cast/convert the following configs in to a List. Eg:

@Value("${name-change}")
private List<Object> changedNames;

OR,

@Value("${name-change}")
private List<ChangedName> changedNames;

where, ChangedName is a POJO class.

Please help me to bind configs in YAML file to a Java List(List<ChangedName> changedNames).

1 Answers1

0

I found this article:

Mapping list in Yaml to list of objects in Spring Boot

It has a similar example and it worked for me.