I have 3 maven projects A, B, C. A is parent project of B and B is the parent of C. All the profiles are defined in the pom.xml
of project A.
In project C, I am trying to select properties file in spring-test-context (under src/test/resources) based on selected profile.For the regression tests, we have 2 properties file :
- application-test-local.properties
- application-test.properties
On our windows development system, selected profile will be "local" and on the servers accordingly. When "local" profile is selected, application-test-local.properties
should be used and application-test.properties
otherwise in the test Spring context. In project C, in spring-test-context.xml
, I tried :
<beans profile="docker">
<util:properties id="metaDbProps" location="application-test-local.properties"/>
</beans>
<beans profile="default">
<util:properties id="metaDbProps" location="application-test.properties"/>
</beans>
However, it seems that application is not able to pass the selected maven profile to spring profile as I am trying "mvn clean test -Pdocker" and it's always picking up the properties file from "default" profile.
Any idea what to fix to pass the maven profile to spring profile so that it can pick up the right properties file?
For understanding, here is how the profiles are defined in project A:
<profiles>
<!-- Windows development -->
<profile>
<id>docker</id>
<activation/>
<properties>
<INSTALL_MACHINE_LIST>localhost</INSTALL_MACHINE_LIST>
<COPY_MODE>local</COPY_MODE>
</properties>
</profile>
<!-- Development -->
<profile>
<id>dev</id>
<activation/>
<properties>
<INSTALL_MACHINE_LIST>dev01</INSTALL_MACHINE_LIST>
</properties>
</profile>
<!-- QA -->
<profile>
<id>qa</id>
<activation/>
<properties>
<INSTALL_MACHINE_LIST>dqa01</INSTALL_MACHINE_LIST>
</properties>
</profile>
<!-- Production -->
<profile>
<id>prod</id>
<activation/>
<properties>
<INSTALL_MACHINE_LIST>prod01</INSTALL_MACHINE_LIST>
</properties>
</profile>
</profiles>