• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
刚子2013
博客园    首页    新随笔    联系   管理    订阅  订阅

maven中profile的激活方式

1.默认激活

Maven给我们提供了多种不同的profile激活方式。比如我们可以使用-P参数显示的激活一个profile,也可以根据环境条件的设置让它自动激活等。

         <profile>
            <id>dev</id>
            <properties>
                <profile.dir>src/main/profiles/dev</profile.dir>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <profile>
            <id>beta-bh</id>
            <properties>
                <profile.dir>src/main/profiles/beta-gn</profile.dir>
            </properties>
        </profile>        

我们可以在profile中的activation元素中指定激活条件,当没有指定条件,然后指定activeByDefault为true的时候就表示当没有指定其他profile为激活状态时,该profile就默认会被激活。所以当我们调用mvn package的时候上面的dev将会被激活,但是当我们使用mvn package -Pbeta-gn的时候将激活beta-gn,而这个时候dev将不会被激活。

2.去掉

<activation>
   <activeByDefault>true</activeByDefault>
</activation>

 

此时激活的为自己配置的。如:

 

则被激活的为beta-gn。如果不去掉activeByDefault,即使使用配置beta-gn,激活的也是dev

 

posted @ 2016-12-19 16:27  刚子2013  阅读(1049)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3