版权所有,未经授权,禁止转载
章节
profile让你能够在特定场景下使用与基本配置不同的配置构建项目。你不需要创建多个单独的POM文件,只需在单个POM文件中包含不同的profile配置,这些profile配置在特定场景下将覆盖pom中的基本配置。
例如,项目中需要构建开发版本、测试版本以及正式版本,这些版本可以通过在pom文件中添加不同构建profile构建。执行maven时指定不同的构建profile就可以。
示例:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.qikegu.demo</groupId> <artifactId>mybatis-demo</artifactId> <version>1.0.0</version> <profiles> <profile> <id>test</id> <activation>...</activation> <build>...</build> <modules>...</modules> <repositories>...</repositories> <pluginRepositories>...</pluginRepositories> <dependencies>...</dependencies> <reporting>...</reporting> <dependencyManagement>...</dependencyManagement> <distributionManagement>...</distributionManagement> </profile> </profiles> </project>
- profile中的元素将覆盖POM中同名元素的值。
<activation>
设置触发profile生效的条件- 也可在maven命令行中指定profile:
-P profile-name
更多细节可参考官方文档