title: Spring - autowired fields are null
body: <p>I faced a problem with Spring Framework: <code>@Autowired</code> are null, but Spring doesn't throw any exceptions, and I can't understand, why are these fields null.</p>
  
  <p>I have a class: </p>
  
  <pre><code>package com.processing.gates;
  
  public class Main {
  
      private final ApplicationContext context = Context.getContext();
  
      @Autowired private PaymentGateFactory paymentGateFactory;
      @Autowired private CalculatorChooser calculatorChooser;
  
      //...
  }
  </code></pre>
  
  <p>And for example I have the following class:</p>
  
  <pre><code>package com.processing.gates.comission;
  
  @Component
  public class CalculatorChooser {
      //...
  }
  </code></pre>
  
  <p>Here is my Spring configuration xml:</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:context="http://www.springframework.org/schema/context"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:jdbc="http://www.springframework.org/schema/jdbc"
         xsi:schemaLocation="http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
          http://www.springframework.org/schema/context
          http://www.springframework.org/schema/context/spring-context-4.1.xsd
          http://www.springframework.org/schema/jdbc 
          http://www.springframework.org/schema/jdbc/spring-jdbc.xsd"&gt;
  
      &lt;context:annotation-config /&gt;
      &lt;context:component-scan base-package="com.processing.gates"/&gt;
  
  
      &lt;bean id="logPath" class="java.lang.String"&gt; &lt;!-- путь к папке с логами --&gt;
          &lt;constructor-arg value="/home/yoba/NetBeansProjects/processing/gates/log/"/&gt;
      &lt;/bean&gt;
      &lt;!-- ... --&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>When I try to write in xml:</p>
  
  <p><code>&lt;bean id="calculator" class="com.processing.gates.comission.CalculatorChooser"/&gt;</code></p>
  
  <p>and get it from code:</p>
  
  <pre><code>CalculatorChooser cc = (CalculatorChooser)Context.getContext().getBean("calculator");
  </code></pre>
  
  <p>it works fine. But @Autowired doesn't work. How can I fix this? Thanks!</p>