I'm trying to inject external.yml
properties into a POJO using @ConfigurationProperties
and importing my external.yml
file using @PropertySource
. All other were injected into POJO but not a complex list.
a. I tried using @NestedConfigurationProperty
for the complex list and map.
b. I tried complex POJO as inner static and outer class.
c. Tried @EnableConfigurationProperties
annotation. etc
ExternalProp.java
@Component
@PropertySource(value = "classpath:external.yml", encoding = "UTF-8")
@ConfigurationProperties
@Data
public class ExternalProp {
private String bla;
private List<Person> persons;
private List<String> other;
@Data
public static class Person {
private int age;
private String name;
private Map<String, String> args;
}
}
external.yml
bla: bkdfjgkdf
persons:
- age: 12
name: bla1
args:
a0: a0dev
a1: a1dev
a2: a2dev
- age: 12
name: bla2
args:
b0: b0dev
b1: b1dev
b2: b2dev
strings: bla, bla1
bla: bkdfjgkdf
and strings: bla, bla1
have been injected properly but not persons. Where am I making mistake.
And same persons
object copied to application.yml
file, then, BOOM, getting values properly.
I'm expecting a List of Persons which is having some Map args
.