title: FactoryBean doesn't use when bean instantiates
body: <p>I am investigating how does <code>FactoryBean</code> works in spring framework.<br>
  As I understand it allow configure instantiation process.</p>
  
  <p>I have the following beans:</p>
  
  <pre><code>@Component
  public class MyInjectionClass {
      String name;
      Integer age;
      //get and set methods
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>@Component
  public class MyComponent {
  
      @Autowired
      MyInjectionClass myInjectionClass; 
  
      public MyInjectionClass getMyInjectionClass() {
          return myInjectionClass;
      }
  }
  </code></pre>
  
  <p>and following cutom <code>FactoryBean</code>:</p>
  
  <pre><code>@Component
  public class MyInjectionClassFactoryBean implements FactoryBean&lt;MyInjectionClass&gt; {
      @Override
      public MyInjectionClass getObject() throws Exception {
          MyInjectionClass myInjectionClass = new MyInjectionClass();
          myInjectionClass.setName("name");
          myInjectionClass.setAge(12);
          return myInjectionClass;
      }
  
      @Override
      public Class&lt;?&gt; getObjectType() {
          return MyInjectionClass.class;
      }
  
      @Override
      public boolean isSingleton() {
          return false;
      }
  }
  </code></pre>
  
  <p>Also I have wrote following code in my main method:</p>
  
  <pre><code>MyComponent bean = context.getBean(MyComponent.class);
  System.out.println(bean.getMyInjectionClass().getAge());
  </code></pre>
  
  <p>It returns null.</p>
  
  <p>What did I forget to do ?</p>
  
  <h2>P.S.</h2>
  
  <p>I use <code>@ComponentScan("com.example.domain")</code></p>
  
  <p>All beans and <code>FactoryBean</code> located there.</p>
  
  <h2>Solution</h2>
  
  <p>remove <code>@Component</code> above <code>MyInjectionClass</code></p>