title: Custom autoconfiguration with multiple beans of same type
body: <p>Using spring-boot-2 I would like to create a custom autoconfiguration that defines a dynamic amount of beans of the same type.</p>
  
  <p>For example I have the following <code>ConfigurationProperties</code> to define an <code>AmazonS3</code> client</p>
  
  <pre class="lang-java prettyprint-override"><code>@Setter
  @Getter
  @ConfigurationProperties("aws")
  public class S3ClientProperties {
      private Map&lt;String, S3Config&gt; s3 = new HashMap&lt;&gt;();
  
      @Setter
      @Getter
      public static class S3Config {
          private String accessKey;
          private String secretKey;
          private String bucketName;
          private String region;
          // ...
      }
  }
  </code></pre>
  
  <p>And if I have a yaml like this:</p>
  
  <pre><code>aws.s3:
    primary:
      bucketName: bucket1
      region: eu-west-1
    secondary:
      bucketName: bucket2
      region: eu-east-1
  </code></pre>
  
  <p>It would be great to get 2 Bean of the type <code>AmazonS3</code> registered to the <code>ApplicationContext</code>, one with the name <code>primary</code>, one with the name <code>secondary</code>.</p>
  
  <p>Is there a more convenient/better way of doing so except having a <code>@PostContstruct</code> on my <code>@Configuration</code>, autowiring the context and adding those beans manually?</p>