title: How do I force a spring container not to return a singleton instance of a bean?
body: <p>When I call <code>getBean(name)</code> on a <code>BeanFactory</code>, I get back an instance of the bean defined in the application context.  However, when I call <code>getBean(name)</code> again (with the same name,) I get the same instance of the bean back.  I understand how this would be desirable in some (many?) cases, but how do I tell the <code>BeanFactory</code> to give me a new instance?</p>
  
  <p>Example Spring configuration (tersely...I've left out some verbosity, but this should get the point across):</p>
  
  <pre><code>&lt;beans&gt;
     &lt;bean id="beanA" class="misc.BeanClass"/&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>Example Java:</p>
  
  <pre><code>for(int i = 0;i++;i&lt;=1) {
      ApplicationContext context = ClassPathXmlApplicationContext("context.xml");
      Object o = context.getBean("beanA");
  
      System.out.println(o.toString());  // Note: misc.BeanA does not implement 
                                         // toString(), so this will display the OOID
                                         // so that we can tell if it's the same
                                         // instance
  }
  </code></pre>
  
  <p>When I run this, I get something like:</p>
  
  <pre><code>misc.BeanClass@139894
  misc.BeanClass@139894
  </code></pre>
  
  <p>Note that both have the same OOID...so these are the same instances...but I wanted different instances.</p>