title: Spring @Autowired comes as null
body: <p>I have <code>@Component</code>, <code>A</code>, which AutoWires a class which contains simple configurations for class <code>A</code>. I've created a bin for configuration file.  But for some reason it comes as null. Could you please help me to find out the problem?</p>
  
  <pre><code>@Component
  public class SearchEngineDriver {
  
      @Autowired(required = true)
      private EngineContext context;
  
  
      public SearchEngineDriver(){
           String clusterName = context.getClusterName();
      }
  }
  
  
  public class EngineContext {
  
      private String clusterName;
  
      public EngineContext(String clusterName){
          this.clusterName = clusterName;
      }
  
      public String getClusterName(){
          return this.clusterName;
      }
  }
  </code></pre>
  
  <p>3rd class.</p>
  
  <pre><code>    @Autowired
      private SearchEngineDriver searchEngineDriver;
  </code></pre>
  
  <p>mvc-dispatcher-servlet.xml</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:mvc="http://www.springframework.org/schema/mvc"
         xmlns:context="http://www.springframework.org/schema/context"
         xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
         http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"&gt;
  
  
  &lt;context:component-scan base-package="org.electronsoftware" /&gt;
      &lt;mvc:annotation-driven/&gt;
      &lt;mvc:resources mapping="/resources/**" location="/resources/" /&gt;
  
      &lt;import resource="classpath*:/application-context.xml"/&gt;
  
      &lt;bean
              class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name="prefix"&gt;
              &lt;value&gt;/&lt;/value&gt;
          &lt;/property&gt;
          &lt;property name="suffix"&gt;
              &lt;value&gt;.jsp&lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>application-context.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:context="http://www.springframework.org/schema/context"
         xsi:schemaLocation="http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans.xsd
         http://www.springframework.org/schema/context
          http://www.springframework.org/schema/context/spring-context-3.2.xsd"&gt;
  
  
      &lt;context:property-placeholder location="classpath:application.properties"/&gt;
  
  
      &lt;bean id="searchEngineContext" class="org.electronsoftware.KGB.search.context.EngineContext" &gt;
          &lt;constructor-arg value="${kgb.search.engine.clustername}"/&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>