Here's a sample application.yml
file
myapp:
resource:
teststring: "string"
testlist:
- "apple"
- "banana"
Here's my immutables configuration class
import org.immutables.value.Value.Immutable;
import org.immutables.value.Value.Modifiable;
@Immutable
@Modifiable
public abstract class ResourceConfiguration {
public abstract String teststring();
public abstract List<String> testlist();
}
Here's my top-level configuration class
@ConstructorBinding
@ConfigurationProperties(prefix = "myapp")
public class MyAppConfiguration {
private final ImmutableResourceConfiguration resource;
public MyAppConfiguration(ImmutableResourceConfiguration resource) {
this.resource = resource.toImmutable();
System.out.println("Look here: "+resource);
}
It reads the teststring
value fine. But the testlist
is empty.
Note that I can read the testlist
fine if it's not wrapped in an Immutables
For example if I changed application.yml to
myapp:
resource:
teststring: "string"
testlist:
- "apple"
- "banana"
and I changed my top-level class to:
@ConstructorBinding
@ConfigurationProperties(prefix = "myapp")
public class MyAppConfiguration {
private final ImmutableResourceConfiguration resource;
public MyAppConfiguration(ImmutableResourceConfiguration resource, List<String> testlist) {
this.resource = resource.toImmutable();
System.out.println("Look here: "+testlist);
}
Then testlist
is correctly populated.
So I'm assuming it has to do with the way the Immutables library processes lists in spring configuration files.