title: How to parse by Spring a name of a variable (key, but not value) from yaml when its name is changing?
body: <p>I have a yaml file with a structure</p>
  <pre><code>section:
    subsections:
      subsectionName1:
        param1: value1
        param2: value2   
      subsectionName2:
        param1: value1
        param2: value2   
  </code></pre>
  <p>I need to parse these properties as <code>List&lt;CustomClass&gt;</code></p>
  <pre><code>@ConfigurationProperties(prefix = &quot;section.subsections&quot;)
  @Configuration
  public class CustomClass {
    
    private final String subsectionName; //the problem is there
    private String param1;
    private String param2;
  
  //Constructors, getters, setters
  </code></pre>
  <p>How can I do this in Spring?</p>
  <p>I see that this works in Micronaut this way:</p>
  <pre><code>import io.micronaut.context.annotation.Context;
  import io.micronaut.context.annotation.EachProperty;
  import io.micronaut.context.annotation.Parameter;
  import lombok.EqualsAndHashCode;
  
  @Context
  @EachProperty(&quot;section.subsections&quot;)
  @EqualsAndHashCode
  public class CustomClass {
    
    private final String subsectionName;
    private String param1;
    private String param2;
   
    public CustomClass(@Parameter String subsectionName) {
      this.subsectionName = subsectionName;
    }
  //getters, setters...
  </code></pre>
  <p>But I didn't manage to find something similar to <code>io.micronaut.context.annotation.Parameter</code> in Spring.</p>
  <p>I need this to use the shared util class which accepts List as a parameter.</p>
  <p>Are there any ideas on how to do this?
  I really appreciate any help you can provide.</p>