title: Spring autowiring not working with lazy-init
body: <p>I am trying to autowire my sessionFactory bean with Spring when I kick off an integration test.  As I am creating a new instance of a service class in my test, I believe I need to lazy-init. For the life of me I have no idea why my sessionFactory continues to be null. Please help!</p>
  
  <p>applicationContext.xml</p>
  
  <pre><code>&lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
      lazy-init="true"&gt;
      &lt;property name="dataSource"&gt;
          &lt;ref bean="dataSource"/&gt;
      &lt;/property&gt;
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
              &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/prop&gt;
              &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>MyServiceImpl.java</p>
  
  <pre><code>@Autowired
  SessionFactory sessionFactory;
  
  public HibernateTemplate getHibernateTemplate() {
      return new HibernateTemplate(this.sessionFactory);
  }
  </code></pre>
  
  <p>Test.java</p>
  
  <pre><code>public void test() {
      MyServiceImpl impl = (MyServiceImpl) Class.forName("foo.package.MyServiceImpl").newInstance();
      HibernateTemplate template = impl.getHibernateTemplate();
  }
  </code></pre>
  
  <p>My "template" variable in the test is always null.</p>