title: Intentionally setting a Spring bean to null
body: <p>I'm using Spring to inject JMS connection factory into my Java application. Since this factory is only required within the production environment, not while I'm developing though, I put the bean definition into a separate XML which I include into my main applicationContext.xml. In production environments this extra file contains the regular bean definition. In my local dev environment I'd like this bean to be null. Trying to simply remove the bean definition all-toghether obviously caused an error when Spring came across a reference ID it didn't know. </p>
  
  <p>So I tried creating a factory bean that would simply return null. If I do this, Spring (2.5.x) complains that the factory returned null although based on the Spring API doc of the FactoryBean interface I expected this to work (see <a href="http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/beans/factory/FactoryBean.html#getObject%28%29" rel="noreferrer">Spring API doc</a>).</p>
  
  <p>The XML looks something like this:</p>
  
  <pre><code>&lt;bean id="jmsConnectionFactoryFactory" class="de.airlinesim.jms.NullJmsConnectionFactoryFactory" /&gt;
  
  &lt;bean id="jmsConnectionFactory" factory-bean="jmsConnectionFactoryFactory" factory-method="getObject"/&gt;
  </code></pre>
  
  <p>What would be the "correct" way of doing this?</p>