一、在settings.xml文件中,都可以配置多个<profile>
<profile>
<id>env-dev</id>
<activation>
<property>
<name>target-env</name>
<value>dev</value>
</property>
</activation>
<properties>
<tomcatPath>/path/to/tomcat/instance</tomcatPath>
</properties>
</profile>
<profile>
<id>cx-cloud</id>
<repositories>
<repository>
<id>cloud-libs-release</id>
<name>libs-release</name>
<url>https://com/artifactory/libs-release</url>
</repository>
<repository>
<snapshots/>
<id>cloud-libs-snapshot</id>
<name>libs-snapshot</name>
<url>https://com/artifactory/libs-snapshot</url>
</repository>
</repositories>
<properties>
<cloud-release-deployment-url>https://com/artifactory/libs-release-local</cloud-release-deployment-url>
<cloud-snapshot-deployment-url>https://com/artifactory/libs-snapshot-local</cloud-snapshot-deployment-url>
</properties>
</profile>
但是,并非所有的<profile>都会被激活,配置生效与否可以通过如下方式进行控制:
在pom.xml文件中通过<profile>的<activation>
在settings.xml文件中通过<profile>的<activation>
在settings.xml文件中通过<activeProfiles>
<activeProfiles>
<activeProfile>cx-cloud</activeProfile>
</activeProfiles>
二、如果注释了激活的配置项,会报错。
1.在构建时,报指定的运行环境配置项不能激活,在setting中定义没有找到id为cx-cloud的配置。

2. 那么就打开setting.xml文件

3. 发现已经注释掉了

4. 那这个激活的配置也注释掉吧,因为目前没有指定项目代码的仓库。

本文介绍了Maven的settings.xml文件中如何控制profile的激活。内容包括在pom.xml和settings.xml中设置profile的激活方式,以及当在settings.xml中通过<activeProfiles>激活profile时,如果注释掉相关配置会引发的错误情况和解决方法。
7203

被折叠的 条评论
为什么被折叠?



