这是我使用Maven的构建配置文件的第一天。我有以下文件模式:Maven设置和POM中的相同配置文件名称
- 的pom.xml
- Maven的设置(%USER_HOME%/平米/ settings.xml中)
出于好奇我在这两个文件中创建一个配置文件使用相同的id(local_deploy),唯一的区别在于一个属性(例如tomcat.pwd)。
档案在POM看起来象下面这样:
<profile>
<id>local_deploy</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<tomcat.host>localhost</tomcat.host>
<tomcat.port>8080</tomcat.port>
<tomcat.url>http://${tomcat.host}:${tomcat.port}/manager/text</tomcat.url>
<tomcat.user>admin</tomcat.user>
<tomcat.pwd>admin</tomcat.pwd>
</properties>
</profile>
档案Maven中设置看起来像如下:
<profile>
<id>local_deploy</id>
<properties>
<tomcat.host>localhost</tomcat.host>
<tomcat.port>8080</tomcat.port>
<tomcat.url>http://${tomcat.host}:${tomcat.port}/manager/text</tomcat.url>
<tomcat.user>admin</tomcat.user>
<tomcat.pwd>wrongpwd</tomcat.pwd>
</properties>
</profile>
请注意,在Maven中设置的个人资料不是<activeProfiles>
上市。
当我尝试使用安装我的应用程序下面的命令
mvn clean install -P local_deploy help:active-profiles
我的应用程序被部署以下输出在控制台上:
The following profiles are active:
local_deploy (source: external)
local_deploy (source: <my groupId>:<my artifactId><version>)
我经历this文档和它说,
Take note that profiles in the settings.xml takes higher priority than profiles in the POM
所以,我假设我的部署应该由于Maven设置中的密码不正确而失败。我在这里错过了什么?
您使用的是哪个版本的maven 3? –
apache-maven-3.3.9 –
我在maven 3.1.1和3.3.9上试过,实际上设置配置文件总是覆盖样本pom中具有相同名称的配置文件的属性。所以文件是正确的,你有没有进一步了解你所报告的行为? –