title: Spring Boot Autowired failed - null
body: <p>I have 3 classes which are found in different packages in a spring boot application as follows:
  Why does <code>@Autowired</code> work in certain classes only?Anything I am doing wrong?</p>
  
  <pre><code>@Configuration
  public class Configurations{
     @Autowired
     Prop prop;  //works fine
  
     @Bean
     //other bean definitions
  
  }
  
  @Component
  public class Prop{
     public void method(){};
  }
  
  public class User{
     @Autowired
     Prop prop;  //does not work, null
  
     public void doWork(){
        prop.method();
     }
  
  }
  </code></pre>
  
  <p>I have also tried the <code>@PostConstruct</code>, but same result</p>
  
  <pre><code>public class User{
         @Autowired
         Prop prop;  //does not work, null
  
         @PostConstruct
         public void doWork(){
            prop.method();
         }
  
      }
  </code></pre>