title: How to configure JPA for testing in Maven
body: <p>Is there a way to set up a second persistence.xml file in a Maven project such that it is used for testing instead of the normal one that is used for deployment?</p>
  
  <p>I tried putting a persistence.xml into src/test/resources/META-INF, which gets copied into target/test-classes/META-INF, but it seems target/classes/META-INF (the copy from the src/main/resources) gets preferred, despite <code>mvn -X test</code> listing the classpath entries in the right order:</p>
  
  <pre><code>[DEBUG] Test Classpath :
  [DEBUG]   /home/uqpbecke/dev/NetBeansProjects/UserManager/target/test-classes
  [DEBUG]   /home/uqpbecke/dev/NetBeansProjects/UserManager/target/classes
  [DEBUG]   /home/uqpbecke/.m2/repository/junit/junit/4.5/junit-4.5.jar
  ...
  </code></pre>
  
  <p>I would like to be able to run tests against a simple hsqldb configuration without having to change the deployment version of the JPA configuration, ideally straight after project checkout without any need for local tweaking.</p>