美文网首页
Maven - profile

Maven - profile

作者: 吴吃辣 | 来源:发表于2019-08-12 15:03 被阅读0次

版权所有,未经授权,禁止转载


章节


profile让你能够在特定场景下使用与基本配置不同的配置构建项目。你不需要创建多个单独的POM文件,只需在单个POM文件中包含不同的profile配置,这些profile配置在特定场景下将覆盖pom中的基本配置。

例如,项目中需要构建开发版本、测试版本以及正式版本,这些版本可以通过在pom文件中添加不同构建profile构建。执行maven时指定不同的构建profile就可以。

示例:

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
   http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.qikegu.demo</groupId>
  <artifactId>mybatis-demo</artifactId>
  <version>1.0.0</version>

  <profiles>
      <profile>
          <id>test</id>
          <activation>...</activation>
          <build>...</build>
          <modules>...</modules>
          <repositories>...</repositories>
          <pluginRepositories>...</pluginRepositories>
          <dependencies>...</dependencies>
          <reporting>...</reporting>
          <dependencyManagement>...</dependencyManagement>
          <distributionManagement>...</distributionManagement>
      </profile>
  </profiles>

</project>
  • profile中的元素将覆盖POM中同名元素的值。
  • <activation>设置触发profile生效的条件
  • 也可在maven命令行中指定profile:-P profile-name

更多细节可参考官方文档

相关文章

  • SpringBoot之条件注解

    背景 之前写过关于Spring和Maven的profile的区别 maven profile VS spring ...

  • maven---灵活构建(一)

    包含内容 maven属性 构建环境的差异 资源过滤 Maven Profile Web资源过滤 在profile中...

  • maven profile多环境配置

    使用maven profile实现多环境配置(代码) maven profile 实现多环境可移植构建 在开发过程...

  • centos7 安装 maven3.5

    下载maven 配置环境变量 vi /etc/profile source /etc/profile

  • Maven - Profile

    什么是profile profile是在maven xml中配置的,由 包围的一块配置 profile的作用 通...

  • Maven - profile

    版权所有,未经授权,禁止转载 章节 Maven – 简介 Maven – 工作原理 Maven – Reposit...

  • maven profile

    profile 能让maven项目在不同的环境下加载不同的配置,在pom文件中加入(如果是多模块项目,加在父POM...

  • 【转载】Maven管理SpringBoot Profile

    Maven管理SpringBoot Profile 1. Spring Profile Spring可使用Prof...

  • Profile

    帮助命令 查看项目中哪些profile被激活了 列出当前所有profile maven属性 maven有6类属性,...

  • 2020-03-19 springboot 打包运行

    打包 指定profile mvn clean package -Pbeta 指定profile以maven命令的方...

网友评论

      本文标题:Maven - profile

      本文链接:https://www.haomeiwen.com/subject/bodujctx.html