title: How to implement dynamic @ConfigurationProperties Prefix
body: <p>I have a requirement to pass dynamic environment name as a prefix of configuration property. I will pass environment as VM argument from command line and all properties should be loaded for that environment. </p>
  
  <p><strong>My Configuration</strong>:</p>
  
  <pre><code>@Configuration
  @EnableConfigurationProperties
  @PropertySource("environmentDetails.yml")
  @ConfigurationProperties(prefix="${environment}")
  public class ConfigurationBean {
  
      private String brokerUrl;
      private String queueName;
      private String receiverUserName;
      private String receiverPassword;
  
      public String getBrokerUrl() {
          return brokerUrl;
      }
      public void setBrokerUrl(String brokerUrl) {
          this.brokerUrl = brokerUrl;
      }
      public String getQueueName() {
          return queueName;
      }
      public void setQueueName(String queueName) {
          this.queueName = queueName;
      }
      public String getReceiverUserName() {
          return receiverUserName;
      }
      public void setReceiverUserName(String receiverUserName) {
          this.receiverUserName = receiverUserName;
      }
      public String getReceiverPassword() {
          return receiverPassword;
      }
      public void setReceiverPassword(String receiverPassword) {
          this.receiverPassword = receiverPassword;
      }
  }
  </code></pre>
  
  <p><strong>environmentDetails.yml</strong></p>
  
  <pre><code>spring:
    profiles.active: default
  ---
  spring:
    profiles: default
  
  environment:
    brokerUrl: http://ip:port
    queueName: testQueue
    receiverUserName: testuser
    receiverPassword: password
  </code></pre>