You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何根据另一个Profile的属性激活Maven通用Profile?

问题排查与修复

先看你POM里的几个关键问题:

  • XML标签拼写错误:全局配置和两个Profile里的<properities>都写错了,正确标签名是<properties>,拼写错误会导致Maven无法解析这些属性配置。
  • arq-common-deps Profile的属性配置格式错误:你用了<property>单标签包裹,Maven中定义属性应该直接在<properties>节点下声明键值对,而非单个<property>标签。
  • 需确保Failsafe插件正确绑定自定义属性:Failsafe默认的跳过参数是skipITs,必须显式配置关联你的skip.integration.tests属性。

修正后的POM配置示例

<properties> 
  <skip.integration.tests>true</skip.integration.tests>
</properties>

<profiles>
  <profile>
    <id>arq-common-deps</id>
    <properties>
        <skip.integration.tests>false</skip.integration.tests>
    </properties>
    <!-- 此处可添加Arquillian通用依赖配置 -->
  </profile>
  <profile>
    <id>arq-glassfish-managed</id>
    <properties> 
       <skip.integration.tests>false</skip.integration.tests>
    </properties>
    <!-- 此处可添加GlassFish Managed容器相关配置 -->
  </profile>
</profiles>

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-failsafe-plugin</artifactId>
      <version>3.2.5</version> <!-- 使用适配项目的插件版本 -->
      <configuration>
        <skip>${skip.integration.tests}</skip>
      </configuration>
      <executions>
        <execution>
          <goals>
            <goal>integration-test</goal>
            <goal>verify</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

测试运行命令

执行集成测试时使用:

mvn verify -Parq-glassfish-managed

激活arq-glassfish-managed Profile后,skip.integration.tests会被设为false,Failsafe插件就会正常执行集成测试代码。

内容的提问来源于stack exchange,提问作者Hantsy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.01 22:22:26