码上敲享录 > maven开发经验分享 > pom.xml的profiles怎么用

pom.xml的profiles怎么用

上一章章节目录下一章 2021-07-19已有900人阅读 评论(0)

pom.xml的profiles怎么用?


解决方法:

springboot为我们提供了一种多环境配置文件选择的解决方案,而maven也提供了一种更加灵活的解决方案,就是profile功能。

如下所示配置了开发、测试、生产三个环境的profile配置,默认(activeByDefault)使用开发环境的配置。

打包开发环境时执行:mvn clean package -Pdev

打包测试环境时执行:mvn clean package -Ptest

打包测试环境时执行:mvn clean package -Pproduct

<profiles>

       <!-- 开发环境,默认激活 -->

       <profile>

           <id>dev</id>

           <properties>

               <skip-test>true</skip-test>

               <env>dev</env>

           </properties>

           <activation>

               <activeByDefault>true</activeByDefault>

           </activation>

       </profile>

<!--开发测试环境 -->

       <profile>

           <id>test</id>

           <properties>

               <skip-test>true</skip-test>

               <env>test</env>

           </properties>

       </profile>

<!-- 生产环境 -->

       <profile>

           <id>product</id>

           <properties>

               <skip-test>true</skip-test>

               <env>product</env>

           </properties>

       </profile>

   </profiles>


向大家推荐《Activiti工作流实战教程》:https://xiaozhuanlan.com/activiti
0

有建议,请留言!

  • *您的姓名:

  • *所在城市:

  • *您的联系电话:

    *您的QQ:

  • 咨询问题:

  • 提 交