How should I configure the eclipse to make use of different values of environment variable for different maven phases, during maven building process?
Prehistory
Our project builds with maven. We use eclipse. In project i have two DB property file:- jdbc.test.properties
- jdbc.prod.properties
with the same structure:
jdbc.driverClassName=
jdbc.url=
jdbc.username=
jdbc.password=
value of username and password in files are different. So we use different schemes for testes and production.
In data-access-config.xml i have the following line:
<context:property-place开发者_StackOverflow社区holder location="classpath:jdbc.${db.flag}.properties"/>
What i do:
- i click "maven install" (in context menu in eclipse)
- maven building process runs
What i want:
- the environment variable "db.flag" was set to "test" during test phase
- the environment variable "db.flag" was set to "prod" during other phases
Now i use bat file:
call mvn test -Ddb.flag=test
call mvn install -Ddb.flag=prod -Dmaven.test.skip=true
But it is not an issue for my team.
How should I configure the eclipse to make use of different values of environment variable for different maven phases, during maven building process?
I'll be glad to any advice.I suggest keeping each copy under the same name (jdbc.properties) in src/main/resources and src/test/resources likewise, so the test phase can pick up your 'test' settings automatically and your location attribute is no longer needed.
Maven will make sure that the test resources are only used at the test phase.
精彩评论