title: @ConfigurationProperties Set<Type>
body: <p>I'd like to have spring load some properties on startup and convert them into the proper types. </p>
  
  <p><strong>application.yml:</strong></p>
  
  <pre><code>base:
    security:
  
      scopes:
        - name: read
          descripton: read some nice things
  
        - name: write
          description: write some nice things
  
      authorities:
        - name: ROLE_ADMIN
          scopes:
            - read
            - write
  
        - name: ROLE_USER
          scopes:
            - read 
  </code></pre>
  
  <p>To load these properties into types I used the following @ConfigurationProperties:
  <strong>BaseProperties.java</strong></p>
  
  <pre><code>@Setter
  @Getter
  @Configuration
  @ConfigurationProperties(prefix="base.security")
  public class BaseProperties {
  
      private Set&lt;ScopeProperty&gt; scopes = new HashSet&lt;&gt;();
      private Set&lt;AuthorityProperty&gt; authorities = new HashSet&lt;&gt;();
  
      @Getter
      @Setter
      public class AuthorityProperty {
          private String name;
          private List&lt;String&gt; scopes;
      }
  
      @Getter
      @Setter
      public class ScopeProperty {
          private String name;
          private String description;
      }
  }
  </code></pre>
  
  <p>Everything I get is a BindException as follows:</p>
  
  <pre><code>Caused by: org.springframework.boot.context.properties.bind.UnboundConfigurationPropertiesException: The elements [base.security.authorities[0].name,base.security.authorities[0].scopes[0],base.security.authorities[0].scopes[1],base.security.authorities[1].name,base.security.authorities[1].scopes[0]] were left unbound.
      at org.springframework.boot.context.properties.bind.IndexedElementsBinder.assertNoUnboundChildren(IndexedElementsBinder.java:136)
      at org.springframework.boot.context.properties.bind.IndexedElementsBinder.bindIndexed(IndexedElementsBinder.java:113)
      at org.springframework.boot.context.properties.bind.IndexedElementsBinder.bindIndexed(IndexedElementsBinder.java:86)
      at org.springframework.boot.context.properties.bind.IndexedElementsBinder.bindIndexed(IndexedElementsBinder.java:71)
      at org.springframework.boot.context.properties.bind.CollectionBinder.bindAggregate(CollectionBinder.java:49)
      at org.springframework.boot.context.properties.bind.AggregateBinder.bind(AggregateBinder.java:56)
      at org.springframework.boot.context.properties.bind.Binder.lambda$bindAggregate$2(Binder.java:293)
      at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:429)
      at org.springframework.boot.context.properties.bind.Binder$Context.access$100(Binder.java:372)
      at org.springframework.boot.context.properties.bind.Binder.bindAggregate(Binder.java:293)
      at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:254)
      at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:214)
  </code></pre>
  
  <p><strong>solution:</strong></p>
  
  <p>Either <strong>mark the classes as static</strong> or <strong>create them as seperate classes</strong>:</p>
  
  <pre><code>    @Getter
      @Setter
      public static class AuthorityProperty {
          private String name;
          private List&lt;String&gt; scopes;
      }
  
      @Getter
      @Setter
      public static class ScopeProperty {
          private String name;
          private String description;
      }
  </code></pre>