title: Autowired throws null pointer
body: <p>I am getting a null pointer exception while auto wiring one of my classes.</p>
  
  <p>I have tried using different annotations such as <code>@Component</code> and <code>@ComponentScan</code></p>
  
  <pre><code>public class ClassA {
      public final String str = "String";
  
      public ClassA(){
          System.out.println("Class A initiated");
      }
  }
  
  
  public class ClassB {
  
      @Autowired
      public ClassA classA;
  
      public ClassB(){
       System.out.println(classA.str);
      }
  
  
  }
  
  @Configuration
  public class Config {
  
      @Bean
      public ClassA classA(){
          return new ClassA();
      }
  
      @Bean
      public ClassB classB(){
          return new ClassB();
      }
  }
  </code></pre>
  
  <p>Stacktrace :</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'classB' defined in class path resource [com/test/demo/Config.class]: Bean instantiation via factory method failed;
  nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.test.demo.ClassB]: Factory method 'classB' threw exception; nested exception is java.lang.NullPointerException
  </code></pre>