title: ConfigurationProperties does not bind properties
body: <p>I want to bind my application.properties into a class automatically by using @ConfigurationProperties annotation. First, I tried with @Value annotation and was able to inject property values into class variables. However, @ConfigurationProperties did not inject properties into values.</p>
  
  <p>my application.properties:</p>
  
  <pre><code>spring.jpa.show-sql=false
  my.url=my_url
  my.name=muatik
  </code></pre>
  
  <p>application.java</p>
  
  <pre><code>package com.muatik;
  
  import org.springframework.beans.factory.annotation.Value;
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.context.ApplicationContext;
  
  
  @SpringBootApplication
  public class Application {
  
      public static void main(String[] args) {
          final ApplicationContext ctx = SpringApplication.run(Application.class, args);
          final ConfigBinder confs = ctx.getBean(ConfigBinder.class);
          System.out.println(confs.getUrl());
          System.out.println(confs.getName());
      }
  
  }
  </code></pre>
  
  <p>ConfigBinder.java</p>
  
  <pre><code>package com.muatik;
  
  import org.springframework.beans.factory.annotation.Value;
  import org.springframework.boot.context.properties.ConfigurationProperties;
  import org.springframework.stereotype.Component;
  
  
  
  @Component
  @ConfigurationProperties(prefix="my")
  public class ConfigBinder {
  
      @Value("${my.name}")
      private String name;
  
      private String url; // expected to be filled automatically
  
      public String getUrl() {
          return this.url;
      }
  
      public String getName() {
          return this.name;
      }
  }
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>...
  2017-01-18 15:19:29.720  INFO 4153 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
  2017-01-18 15:19:29.724  INFO 4153 --- [           main] com.muatik.Application                   : Started Application in 4.212 seconds (JVM running for 4.937)
  null
  muatik
  </code></pre>
  
  <p>What is the wrong with this implementation?</p>
  
  <p><strong>edit and solution</strong>:
  possible duplication: <a href="https://stackoverflow.com/questions/28485442/spring-boot-configurationproperties-not-retrieving-properties-from-environment?rq=1">Spring Boot @ConfigurationProperties not retrieving properties from Environment</a></p>
  
  <p>I found that I missed the setters in ConfigBinder. After adding them, it works now.</p>