您的位置:首页 > 其它

Maven实现在不同的开发环境下打不同的包

2016-08-30 18:21 357 查看
在项目的主pom.xml文件中引入如下代码:

<!-- 不同的打包环境 -->
<profiles>
<!-- 开发环境,默认激活 -->
<profile>
<id>dev</id>
<properties>
<env>dev</env>
</properties>
<activation>
<activeByDefault>true</activeByDefault><!--默认启用的是dev环境配置 -->
</activation>
</profile>
<!-- 生产环境 -->
<profile>
<id>production</id>
<properties>
<env>production</env>
</properties>
<activation>
<activeByDefault>false</activeByDefault><!--默认启用的是dev环境配置 -->
</activation>
</profile>
<!-- 测试环境 -->
<profile>
<id>test</id>
<properties>
<env>test</env>
</properties>
</profile>
</profiles>


在配置好的maven环境中,使用cmd命令进行打包:

这是生产环境下的包

clean package -P production

这是测试环境下的包

clean package -P test

这是开发环境下的包

clean package -P test
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐