Maven的pom.xml文件结构之Build配置build

这篇博客详细介绍了Maven的pom.xml中<build>配置,包括Project Build和Profile Build,以及它们共有的defaultGoal、directory、finalName、<resources>、<plugins>、<pluginManagement>等元素。此外,还讲解了Project Build特有的<...Directory>和<extensions>,阐述了它们在构建过程中的作用和用法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在Maven的pom.xml文件中,Build相关配置包含两个部分,一个是<build>,另一个是<reporting>,这里我们只介绍<build>。


1. 在Maven的pom.xml文件中,存在如下两种<build>:

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  ...
  <!-- "Project Build" contains elements of the BaseBuild set and the Build set-->
  <build>...</build>
 
  <profiles>
    <profile>
      <!-- "Profile Build" contains elements of the BaseBuild set only -->
      <build>...</build>
    </profile>
  </profiles>
</project>
说明:

一种<build>被称为Project Build,即是<project>的直接子元素。另一种<build>被称为Profile Build,即是<profile>的直接子元素。

Profile Build包含了基本的build元素,而Project Build还包含两个特殊的元素,即各种<...Directory>和<extensions>。


2. Profile Build和Project Build共用的基本build元素

1) 示例如下:

<build>
  <defaultGoal>install</defaultGoal>
  <directory>${basedir}/target</directory>
  <finalName>${artifactId}-${version}</finalName>
  ...
</build>
评论 21
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值