如何通过maven属性激活配置文件? [英] How to activate profile by means of maven property?

查看:171
本文介绍了如何通过maven属性激活配置文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 pom.xml 中定义的属性激活maven配置文件:

I'm trying to activate a maven profile using a property defined inside pom.xml:

<project>
  [...]
  <properties>
    <run.it>true</run.it>
  </properties>
  [...]
  <profiles>
    <profile>
      <activation>
        <property><name>run.it</name></property>
      </activation>
      [...]
    </profile>
  </profiles>
  [...]
</project>

显然它不起作用。但是,激活可以从命令行进行:

Apparently it doesn't work. However, activation works from the command line:

mvn -Drun.it

是按设计吗?如果是,那么可能的解决方法是什么?

Is it "by design"? If it is, what is a possible workaround?

推荐答案

编辑,完成重写,因为我现在理解了这个问题。

Edit, complete rewrite, as i understand the question now.

参见此论坛帖子


配置文件激活基于 SYSTEM 属性。
您无法根据您的pom中定义的属性激活配置文件
您无法根据
构建计划开始执行后定义的系统属性激活配置文件

profile activation is based on SYSTEM properties. you cannot activate profiles based on properties defined in your pom you cannot activate profiles based on system properties defined after the build plan has started execution

这篇关于如何通过maven属性激活配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆