用户工具

站点工具


分享:技术:maven:profile的介绍和使用

这是本文档旧的修订版!


profile的介绍和使用

profile的介绍

同一个项目使用同一个pom.xml来构建不同的环境时候,比如:本地环境(local)日志输出目录:D:/logs/record/record.log,而测试环境(test)日志输出目录:/home/gxx/logs/record/record.log;又比如:本地环境(local)使用数据源1,而测试环境(test)使用数据源2。

profile的使用

<!-- 使用 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>
分享/技术/maven/profile的介绍和使用.1436778154.txt.gz · 最后更改: 2015/07/13 17:02 由 gxx