title: Spring property name casing by example
body: <p>Spring will automatically bind properties defined in <code>application.properties</code> or <code>application.yml</code> to fields defined in <code>@ConfigurationProperties</code>-annotated classes. For instance, in my <code>application.properties</code> I can have:</p>
  <pre><code>fizz.buzz=35
  fizz.foo=hello
  </code></pre>
  <p>And in my Java code I can have:</p>
  <pre><code>@ConfigurationProperties(&quot;fizz&quot;)
  public class FizzProperties {
      private Integer buzz;
      private String foo;
      // ...
  }
  </code></pre>
  <p>And at runtime <code>FizzProperties#buzz</code> will get a value of <code>35</code> injected into it and <code>FizzProperties#foo</code> will have a value of <code>&quot;hello&quot;</code> injected into it.</p>
  <p>I'm wondering what the naming convention is for camel-cased Java fields, and also for hyphens (<code>&quot;-&quot;</code>) and periods (<code>&quot;.&quot;</code>) used in the properties files. For instance, if I had:</p>
  <pre><code>fizz.whistle-feather=true
  fizz.baz.boo=always
  </code></pre>
  <p>What would their corresponding Java fields need to look like in order for Spring to map and inject them properly?</p>
  <pre><code>public class Baz {
      private String boo;
  }
  
  @ConfigurationProperties(&quot;fizz&quot;)
  public class FizzProperties {
      private Integer whistleFeather; // correct?
      private Baz baz; // correct?
      // ...
  }
  </code></pre>
  <p><strong>Are my assumptions correct here or misled (and if misled, how so)?</strong> I can't find this explained in the Spring docs.</p>