title: Importing resource conditionally in spring application context
body: <p>Can I import things in a spring context only if a certain condition is met?</p>
  
  <pre><code>&lt;!-- import ONLY IF current environment is NOT testing --&gt;
  &lt;import resource="classpath:context/caching-context.xml" /&gt;
  </code></pre>
  
  <p>currently I am doing that by importing a totally different context in my testcases</p>
  
  <pre><code>@ContextConfiguration(locations = { "classpath*:ApplicationContextTesting.xml" })
  </code></pre>
  
  <p>but maybe there is a more elegant solution to not maintain two separate application contexts for production and testing.</p>