这是本文档旧的修订版!
同一个项目使用同一个pom.xml来构建不同的环境时候,比如:本地环境(local)日志输出目录:D:/logs/record/record.log,而测试环境(test)日志输出目录:/home/gxx/logs/record/record.log;又比如:本地环境(local)使用数据源1,而测试环境(test)使用数据源2。
<!-- 使用 mvn clean install -P XXX 激活profile --> <!-- mvn clean install #默认local --> <!-- mvn clean install -P local #选择本地环境 --> <!-- mvn clean install -P test #选择test环境--> <profiles> <profile> <id>local</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <deploy.environment.include>local</deploy.environment.include> <deploy.environment.exclude>test</deploy.environment.exclude> <log4j.dir>D:/logs/record/record.log</log4j.dir> </properties> </profile> <profile> <id>test</id> <properties> <deploy.environment.include>test</deploy.environment.include> <deploy.environment.exclude>local</deploy.environment.exclude> <log4j.dir>/home/gxx/logs/record/record.log</log4j.dir> </properties> </profile> </profiles>