Reputation: 51
I'm working with a library that uses nested properties for configuration.
E.g.
@Value("${foo.bar}") String fooBar;
@Value("${foo.bar.baz}") String fooBarBaz;
This can be represented successfully in the following properties file:
foo.bar=abc
foo.bar.baz=xyz
However, I've been unable to find a way to represent this in a YML file. Can this even be done? I've tried the following:
// Invalid (ScannerException).
foo:
bar: abc
baz: xyz
// Invalid (NullPointerException).
foo:
bar:
~: abc
baz: xyz
// Invalid (DuplicateKeyException).
foo:
bar: abc
bar:
baz: xyz
Upvotes: 2
Views: 360
Reputation: 51
Actually, I just realized this could be done by collapsing the nesting into the key.
E.g.
foo:
bar: abc
bar.baz: xyz
Upvotes: 3