I’ve got standart maven folder structure:
src/main/java
src/main/resources
src/test/java
src/test/resources
My appicationContext contains following:
<!-- load properties files -->
<context:property-placeholder location="classpath*:*.properties"/>
I have defined 2 hibernate.properties files – one for src/main/resources and one for src/ test/resources. I have expected that when I will run tests my test hibernate.properties will override production hibernate.properties. Instead of that both files are loaded and production version is used:
Loading properties file from file [D:\projects\video_crawler_v3\out\test\core\hibernate.properties]
Loading properties file from file [D:\projects\video_crawler_v3\out\production\core\hibernate.properties]
How can I correctly setup my properties files? I’m using Intellij IDEA to compile and run tests
One of the options is Spring Profiles http://blog.springsource.com/2011/02/11/spring-framework-3-1-m1-released/
Put two “properties” versions in your context.xml, eg:
Activate required profile with -Dspring.profiles.active=test.
Note: use http://www.springframework.org/schema/beans/spring-beans-3.1.xsd