title: Common strategies when defining Spring beans for different environments
body: <p>What are common strategies for defining a bunch of beans, which are used differently in development and production environments?</p>
  
  <p>Let's say I have 2 beans, each implementing the same interface. One bean serves as abstraction for local filesystem, the other connects to a distributed filesystem. To keep the development as steady, as possible, the development environment should use local filesystem implementation, the production release uses distributed filesystem bean.</p>
  
  <p>Currently what I'm doing is having two xml definitions.</p>
  
  <p><strong>native.xml</strong></p>
  
  <pre><code>&lt;bean id="resourceSystem" class="com.cust.NativeResourceSystem" /&gt;
  </code></pre>
  
  <p><strong>distributed.xml</strong></p>
  
  <pre><code>&lt;bean id="resourceSystem" class="com.cust.HadoopResourceSystem"&gt;
      &lt;constructor-arg name="fs" ref="hdfs" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>When creating application context I omit either <code>native.xml</code> or <code>distributed.xml</code> depending on environment and grab the <code>resourceSystem</code> bean.</p>
  
  <p>Are there any proper tools or best practices in Spring to configure bean definitions for different environments?</p>
  
  <p>Thanks.</p>