Prehistory
Our project builds with maven. We use eclipse.
In project i have two DB property file:
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-placeholder location="classpath:jdbc.${db.flag}.properties"/>
What i do:
What i want:
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.