title: Use constructor injection for spring ConfigurationProperties subclasses
body: <p>I was looking at this <a href="https://www.baeldung.com/configuration-properties-in-spring-boot" rel="noreferrer">https://www.baeldung.com/configuration-properties-in-spring-boot</a> and was wondering if it was possible to use constructor injection for these in order to enforce some immutability properties.</p>
  
  <p>For example would it be possible to do this:</p>
  
  <pre><code>@Component
  @ConfigurationProperties("my-config")
  public class MyConfig {
  
      private final List&lt;String&gt; values;
  
      public MyConfig(@Value("${values}") List&lt;String&gt; values) {
          this.values = ImmutableList.copyOf(values);
      }
  }
  </code></pre>
  
  <p>And then in my yml config have</p>
  
  <pre><code>my-config.values:
    - foo
    - bar
  </code></pre>
  
  <p>But I get this error:</p>
  
  <pre><code>java.lang.IllegalArgumentException: Could not resolve placeholder 'values' in string value "${values}"
  </code></pre>