Java Maven wildfly:deploy-P profileX不会触发正确的概要文件
我在Maven的settings.xml中有两个配置文件,但我无法通过-p选项触发它们,始终使用第二个:Java Maven wildfly:deploy-P profileX不会触发正确的概要文件,java,maven,Java,Maven,我在Maven的settings.xml中有两个配置文件,但我无法通过-p选项触发它们,始终使用第二个: <profiles> <profile> <id>wilfly-local</id> <activeByDefault>true</activeByDefault> <properties> <wildfly-hostname>
<profiles>
<profile>
<id>wilfly-local</id>
<activeByDefault>true</activeByDefault>
<properties>
<wildfly-hostname>127.0.0.1</wildfly-hostname>
<wildfly-port>zzzz</wildfly-port>
<wildfly-username>xxx</wildfly-username>
<wildfly-password>S3cret</wildfly-password>
</properties>
</profile>
<profile>
<id>wildfly-remote</id>
<activeByDefault>false</activeByDefault>
<properties>
<wildfly-hostname>192.168.xxx.yyy</wildfly-hostname>
<wildfly-port>zzzz</wildfly-port>
<wildfly-username>xxx2</wildfly-username>
<wildfly-password>S3cret</wildfly-password>
</properties>
</profile>
</profiles>
...
<activeProfiles>
<activeProfile>wildfly-local</activeProfile>
<activeProfile>wildfly-remote</activeProfile>
</activeProfiles>
My pom.xml:
...
<build>
<finalName>mvnweb</finalName>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.2.1.Final</version>
<configuration>
<hostname>${wildfly-hostname}</hostname>
<port>${wildfly-port}</port>
<username>${wildfly-username}</username>
<password>${wildfly-password}</password>
</configuration>
</plugin>
</plugins>
</build>
...
问题是当我尝试mvnwildfly:deploy-pwildfly-local时,Maven在远程服务器上部署war文件。
当我改变配置文件的顺序,然后使用第二个配置文件时,我在运行它时用-X选项检查了它。两个概要文件都正确部署了项目。
activeByDefault标记不做任何事情,如果我将其注释掉,结果保持不变。
有人能告诉我怎样才能让P触发器正常工作吗?
提前谢谢 来自:
settings.xml拼图的最后一块是activeProfiles元素。这包含一组activeProfile元素,每个元素都有一个配置文件id值。任何定义为activeProfile的配置文件id都将处于活动状态,不受任何环境设置的限制。如果没有找到匹配的配置文件,则不会发生任何情况。例如,如果env test是activeProfile,则pom.xml或profile.xml中具有相应id的概要文件将处于活动状态。如果没有找到这样的配置文件,则执行将继续正常进行
因为您在settings.xml中指定了两个配置文件,所以它们都被激活。第二个可能会覆盖属性
如果要启用-p CLI参数,则应从settings.xml中删除activeProfiles
<activeProfiles>
<activeProfile>wildfly-local</activeProfile>
<activeProfile>wildfly-remote</activeProfile>
</activeProfiles>
是的,它起作用了!我只删除了wildfly remote,现在默认为local,当我想在远程服务器上部署时,我可以使用-P选项。谢谢