title: @ConfigurationProperties is not working with .YAML files
body: <p>i am newbie to SpringBoot and trying to read the properties from YML file using in built SpringBoot annotations.</p>
  
  <p>following is the code:</p>
  
  <blockquote>
    <p>AppProperties.java</p>
  </blockquote>
  
  <pre><code>@Component
  @ConfigurationProperties(prefix = "patterns")
  public class AppProperties {
  
      private List&lt;PasswordPattern&gt; password_patterns = new ArrayList&lt;&gt;();
  
      public static class PasswordPattern {
          private String pattern1;
  
          @Autowired
          public String getPattern1() {
              return pattern1;
          }
  
          public void setPattern1(String pattern1) {
              this.pattern1 = pattern1;
          }
      }
  
  }
  </code></pre>
  
  <p>Test class where AppProperties being called</p>
  
  <blockquote>
    <p>Test1.java</p>
  </blockquote>
  
  <pre><code>public class Test1 {
  
      public static void main(String[] args) throws JsonParseException, JsonMappingException, IOException {
          // TODO Auto-generated method stub
  
          AppProperties.PasswordPattern a = new AppProperties.PasswordPattern();
  
          System.out.println(a.getPattern1());
      }
  
  }
  </code></pre>
  
  <blockquote>
    <p>application.yml file</p>
  </blockquote>
  
  <pre><code>--- 
  patterns: 
    password_patterns: 
    pattern1: "test"
  </code></pre>
  
  <p>EXPECTATION:  is that getPattern1() method should return the value read from the yml file </p>
  
  <p>i referred many posts for such issues , but not getting what is the mistake i am doing. have i missed any specific annotation ? i red about </p>
  
  <blockquote>
    <p>@Autowired</p>
  </blockquote>
  
  <p>it is related to dependency injection and i have used that also ...
  please suggest </p>
  
  <p>FURTHER EDITS: </p>
  
  <p>after following the post from "Alexander pinkin" , getting following error :</p>
  
  <pre><code>***************************
  APPLICATION FAILED TO START
  ***************************
  
  Description:
  
  Failed to bind properties under 'patterns.password-patterns' to java.util.Map&lt;ja
  va.lang.String, java.lang.String&gt;:
  
      Reason: No converter found capable of converting from type [java.lang.String
  ] to type [java.util.Map&lt;java.lang.String, java.lang.String&gt;]
  
  Action:
  
  Update your application's configuration
  </code></pre>
  
  <p>FURTHER EDIT 2:</p>
  
  <blockquote>
    <p>AppProperties.java</p>
  </blockquote>
  
  <pre><code>@Component
  @ConfigurationProperties(prefix = "patterns")
  public class AppProperties {
  
      private List&lt;Menu&gt; menus = new ArrayList&lt;&gt;();
  
      public static class Menu {
          private String pattern1;
  
          public String getPattern1() {
              return pattern1;
          }
  
          public void setPattern1(String pattern1) {
              this.pattern1 = pattern1;
          }
  
      }
  }
  </code></pre>
  
  <blockquote>
    <p>PasswordpatApplication.java</p>
  </blockquote>
  
  <pre><code>@SpringBootApplication
  @EnableConfigurationProperties(AppProperties.class)
  public class PasswordpatApplication {
  
      private static final Logger LOG = LoggerFactory.getLogger(PasswordpatApplication.class);
  
      @Autowired
      public static void main(String[] args) {
          SpringApplication.run(PasswordpatApplication.class, args);
  
          AppProperties.Menu a = new AppProperties.Menu();
          LOG.info("hi");
          LOG.info(a.getPattern1());
  
      }
  </code></pre>
  
  <blockquote>
    <p>application.yml</p>
  </blockquote>
  
  <pre><code>patterns: 
    password-patterns: 
    pattern1: test
  </code></pre>
  
  <p>OUTPUT:</p>
  
  <pre><code>  .   ____          _            __ _ _
   /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
  ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
   \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
    '  |____| .__|_| |_|_| |_\__, | / / / /
   =========|_|==============|___/=/_/_/_/
   :: Spring Boot ::        (v2.0.4.RELEASE)
  
  2018-08-24 18:56:21.116  INFO 11712 --- [           main] c.e.passwordpat.Passwo
  rdpatApplication   : Starting PasswordpatApplication v0.0.1-SNAPSHOT on PUNITP13
  0066L with PID 11712 (C:\Users\irfan.sayed\Downloads\passwordpat\target\password
  pat-0.0.1-SNAPSHOT.jar started by irfan.sayed in C:\Users\irfan.sayed\Downloads\
  passwordpat\target)
  2018-08-24 18:56:21.131  INFO 11712 --- [           main] c.e.passwordpat.Passwo
  rdpatApplication   : No active profile set, falling back to default profiles: de
  fault
  2018-08-24 18:56:21.271  INFO 11712 --- [           main] s.c.a.AnnotationConfig
  ApplicationContext : Refreshing org.springframework.context.annotation.Annotatio
  nConfigApplicationContext@6c629d6e: startup date [Fri Aug 24 18:56:21 IST 2018];
   root of context hierarchy
  2018-08-24 18:56:22.066  WARN 11712 --- [           main] f.a.AutowiredAnnotatio
  nBeanPostProcessor : Autowired annotation is not supported on static methods: pu
  blic static void com.example.passwordpat.PasswordpatApplication.main(java.lang.S
  tring[])
  2018-08-24 18:56:23.887  INFO 11712 --- [           main] o.s.j.e.a.AnnotationMB
  eanExporter        : Registering beans for JMX exposure on startup
  2018-08-24 18:56:23.920  INFO 11712 --- [           main] c.e.passwordpat.Passwo
  rdpatApplication   : Started PasswordpatApplication in 3.484 seconds (JVM runnin
  g for 4.104)
  2018-08-24 18:56:23.929  INFO 11712 --- [           main] c.e.passwordpat.Passwo
  rdpatApplication   : hi
  2018-08-24 18:56:23.931  INFO 11712 --- [           main] c.e.passwordpat.Passwo
  rdpatApplication   : null
  2018-08-24 18:56:23.938  INFO 11712 --- [       Thread-2] s.c.a.AnnotationConfig
  ApplicationContext : Closing org.springframework.context.annotation.AnnotationCo
  nfigApplicationContext@6c629d6e: startup date [Fri Aug 24 18:56:21 IST 2018]; ro
  ot of context hierarchy
  2018-08-24 18:56:23.946  INFO 11712 --- [       Thread-2] o.s.j.e.a.AnnotationMB
  eanExporter        : Unregistering JMX-exposed beans on shutdown
  </code></pre>
  
  <p>now , nothing is getting printed on the console. neither any error OR exception </p>
  
  <p>please suggest</p>