title: How to make @autowire work in spring when creating instance manually
body: <p><br/>
  I have a java interface say ITest implemented by two classes Class1 and Class2. Now I have a factory class which I use to decide which implementation to return. like <br/></p>
  
  <pre><code>if(something)
      return new Class1()
  else
     return new Class2()
  </code></pre>
  
  <p>Problem is that I have autowired field in Class1 which doesn't get instantiated,, but the same autowiring works in other classes which were instantiated via autowiring. <br/>
  Here is code for Class1<br/></p>
  
  <pre><code>@Componene
  public Class1 implements ITest{
    @Autowired
    private SomeClass obj;
  }
  </code></pre>
  
  <p>Not sure how to get around this problem. As autowiring for SomeClass works fine in Other classes.</p>