title: Spring + Maven: separate property files for unit tests and integration tests
body: <p>I'm using Spring 2.5.6 and building my project with Maven 2.2.1. We use <code>PropertyPlaceholderConfigurer</code> beans in Spring to load up properties for configuring things like the database. Pretty standard stuff. We also have two different sets of tests: unit tests and integration tests. </p>
  
  <p>I would like to be able to use different property files to configure things like database url differently for the two different types of tests. For example, I want unit tests to use the <code>localhost</code> database and integration tests to use the <code>mydatabase.example.com</code> database.</p>
  
  <p>I have tried several variations where I place the property files in separate subdirectories (one for unit tests and one for integration tests). From there, I've tried things like using the <code>additionalClasspathElements</code> tag for the <code>maven-failsafe-plugin</code>, but that didn't seem to work at all. I tried using the <code>maven-antrun-plugin</code> to copy the files into <code>target/classes</code>, but that didn't get triggered when I ran <code>mvn verify -Dtest=sometest</code>.</p>
  
  <p>I also tried using <code>systemPropertyVariables</code> in maven to set a property called <code>buildEnvironment</code>, which I then tried to reference in my Spring bean definition:</p>
  
  <pre><code>&lt;property name="locations"&gt;
    &lt;value&gt;classpath:${buildEnvironment}/my-test.properties&lt;/value&gt;
  &lt;/property&gt;
  </code></pre>
  
  <p>But Spring refused to resolve <code>${buildEnvironment}</code>. At this point I'm out of ideas. I'm sure there's a nice, straightforward way to do this, but I can't figure it out.</p>
  
  <p>Any advice would be greatly appreciated.</p>