title: Spring prefix using @ConfigurationProperties with @Value in the constructor
body: <p>I am running my application with Spring Boot (1.2.0.RELEASE) using the @SpringBootApplication annotation.</p>
  
  <p>What I try to achieve is to have the following without using long prefixes in each @Value annotation:</p>
  
  <p>application.properties</p>
  
  <pre><code>prefix.key1=value1
  prefix.key2=value2
  </code></pre>
  
  <p>DefaultService.java</p>
  
  <pre><code>@Service
  @ConfigurationProperties("prefix")
  public class DefaultService implements Service {
      private final String key1;
      private final String key2;
  
      @Autowired
      public DefaultService(@Value("${key1}") final String key1, @Value("${key2}") final String key2) {
          this.key1 = key1;
          this.key2 = key2;
      }
  }
  </code></pre>
  
  <p>I know that this can be done without using @Value and in need of setters (<a href="https://stackoverflow.com/questions/27416327/configurationproperties-prefix-not-working">@ConfigurationProperties prefix not working</a>) or with <a href="http://docs.spring.io/spring-boot/docs/1.2.0.RELEASE/reference/htmlsingle/#boot-features-external-config-typesafe-configuration-properties" rel="nofollow noreferrer">http://docs.spring.io/spring-boot/docs/1.2.0.RELEASE/reference/htmlsingle/#boot-features-external-config-typesafe-configuration-properties</a> but I try to achieve it in the constructor.</p>