I have a configuration class named CommonConfig that has been working fine so far…
@Data
@Component
@ConfigurationProperties(prefix = “my")
public class CommonConfig {
  private String foo;
  private String bar;
  private SubA subA;
  @Data 
  public static class SubA {
    private String baz;
    private SubB subB;
    @Data 
    public static class SubB {
      private String qux;
    }
  }
}
And the Yaml property file to go with that:
my.foo: a
my.bar: b
my.sub-a.baz: c
my.sub-a.sub-b.qux: d
My problem started when I wanted to get a map into SubB:
my:
  foo: a
  bar: b
  sub-a:
    baz: c
    sub-b:
      qux: d
      map:
        number-one: 1
        number-two: 2
        number-three: 3
I tried adding a simple map declaration inside my SubB class:
...
@Data 
public static class SubB {
  private String qux;
  private Map<String, Integer> map = new HashMap<>();
}
When I run this though, all the other properties are in the config, but the map is empty. I also tried not initializing the map, but it stays null.
My @SpringBootApplication class has previously been working fine with just that one annotation on it.  Based on some other StackOverflow questions, I tried adding @EnableConfigurationProperties, but it made no difference.