ContextConfiguration(locations = { "/my_spring_test.xml" })
public abstract class AbstractMyTestCase extends AbstractJUnit4SpringContextTests
and in my_spring_test.xml, I'd use the PropertyPlaceHolderConfigurer mechanism.
Example for JPA:
Now all you need to do is have different versions of test.properties on the class path for in-memory and real integration tests (and of course the respective driver classes need to be present). You can even set system properties to overwrite the property values.
If you want to prepare this with maven, you will find that copying files with maven is not trivial. You will need a way to execute code, the standard choices being the maven-antrun-plugin and gmaven-maven-plugin.
Either way: have two configuration files, e.g. in src/main/config and add two plugin executions, one in phase generate-test-resources and one in phase pre-integration-test. Here's the GMaven version:
org.codehaus.gmavengmaven-plugin1.3pre-integration-testexecute
new File(
pom.build.testOutputDirectory,
"test.properties"
).text = new File(
pom.basedir,
"src/main/config/int-test.properties"
).text;
generate-test-resourcesexecute
new File(
pom.build.testOutputDirectory,
"test.properties"
).text = new File(
pom.basedir,
"src/main/config/memory-test.properties"
).text;