I am using @ConfigurationProperties
@Getter
@Setter
@ConfigurationProperties(prefix = "my")
@Component
public class MyProperties {
private Nested single;
private List<Nested> many;
}
@Getter
@Setter
public class Nested {
private String foo;
private String bar;
}
test.properties
my.single.foo=A
my.single.bar=B
my.many[0].foo=C
my.many[0].bar=D
I am running test with the following configuration:
@TestPropertySource(locations = "classpath:test.properties",
properties = {
"my.single.bar=bb",
"my.many[0].bar=dd"
})
The problem is that I get my.many[0].foo=null
because as I understood Spring completely replaces first element in list with {foo: null, bar: "dd"}
Please help.