【问题标题】:How to specify active profiles in Maven3如何在 Maven3 中指定活动配置文件
【发布时间】:2011-01-22 05:45:15
【问题描述】:

我们的应用程序由各种活动配置文件(比如 A1、A2、A3、A5 ...)组成,这些配置文件分别在profiles.xml 文件中定义。 Maven 3 期望将所有配置文件信息存储为 pom.xml 文件本身的一部分。

我应该如何在 pom.xml 文件中指定活动配置文件的列表,这样我就可以避免在命令行中指定它们(例如 mvn -PA1,A2,A3,A5)

【问题讨论】:

    标签: maven profile maven-3


    【解决方案1】:

    应该这样做:

    <profiles>
      <profile>
        <id>profile-1</id>
        <activation>
          <activeByDefault>true</activeByDefault>
        </activation>
        ...
      </profile>
    </profiles>
    

    来自here

    【讨论】:

    • 我无法为多个配置文件指定这个,我认为这个建议不起作用
    【解决方案2】:

    除了@javamonkey79 的答案,您还可以使用settings.xml。有部分配置文件和激活。看下面的例子:

     <profiles>
      <profile>
       <id>hudson-simulate</id>
       <properties>
        <gituser>username</gituser>
        <gitpassword>secret</gitpassword>
       </properties>
      </profile>
      <profile>
       <id>other-profile</id>
       <properties>
        <proerty1>username</property1>
       </properties>
      </profile>
     </profiles>
    
     <activeProfiles>
      <activeProfile>hudson-simulate</activeProfile>
      <activeProfile>other-profile</activeProfile>
     </activeProfiles>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-09
      • 1970-01-01
      • 2020-02-04
      • 1970-01-01
      • 2015-10-20
      • 2018-11-12
      • 1970-01-01
      • 2013-02-14
      相关资源
      最近更新 更多