Maven —— 常用POM文件标签易懂总结

本文详细介绍了Maven项目配置的基本元素及其作用,包括模型版本、父项目与子项目的关系、项目组标识、项目版本等核心配置项,并解释了依赖管理和构建配置等内容。
<?xml version="1.0" encoding="UTF-8"?>
<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">
    <!--模型版本-->
    <modelVersion>4.0.0</modelVersion>

    <!--父项目&子项目-->
    <!--子项目的pom ≈ 自己的pom + 父项目的pom-->
    <!--如果父子项目对于同一属性中有不同的值,以子项目中的为准-->

    <!--父项目的信息-->
    <parent>
        <!--被继承的父项目的groupId-->
        <groupId></groupId>
        <!--被继承的父项目的artifactId-->
        <artifactId></artifactId>
        <!--被继承的父项目的version-->
        <version></version>
        <!-- 父项目的pom.xml文件的相对路径。默认值是../pom.xml。Maven首先在构建当前项目处寻找,其次在relativePath位置,然后在本地仓库,最后在远程仓库。-->
        <relativePath></relativePath>
    </parent>

    <!--项目组的标识,如果不写,默认与父项目groupId保持一致-->
    <groupId></groupId>
    <!--项目的标识,通常是项目的名称-->
    <artifactId></artifactId>
    <!--目前共有三种:pom、jar、war。父级项目一定为pom。默认使用jar方式打包。war打包会把依赖的jar包也打包,部署时使用war,不再需要下载其他依赖。-->
    <packaging></packaging>
    <!--项目版本-->
    <version></version>
    <!--项目名称-->
    <name></name>
    <!--项目主页的URL-->
    <url></url>
    <!-- 项目的详细描述-->
    <description></description>

    <!--自定义属性,可使用${abc}在pom中使用-->
    <properties>
        <abc></abc>
    </properties>

    <!--项目引入插件所需要的额外依赖-->
    <dependencies>
        <dependency>
            <groupId></groupId>
            <artifactId></artifactId>
        </dependency>
    </dependencies>

    <!--dependencyManagement主要用来控制所有子项目依赖的版本号,是当前所有子项目依赖的默认版本号。-->
    <!--如果dependencies与dependencyManagement中的依赖版本号不同,则选用dependencies的依赖版本号。-->
    <dependencyManagement>
        <dependencies>
            <dependency>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <profiles>
        <!--指定build一个project中特定的子modules-->
        <profile>
            <id>default</id>
            <!--默认激活当前配置-->
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <!--需要build的子模块-->
            <modules>
                <module>a</module>
                <module>b</module>
            </modules>
        </profile>

        <!--环境相关-->
        <profile>
            <!--配置文件名-->
            <id>dev</id>
            <!--默认激活当前配置-->
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <!--参数设置-->
            <properties>
                <activatedProperties>dev</activatedProperties>
            </properties>
        </profile>
    </profiles>

    <!--构建项目所需要的信息-->
    <build>
    </build>
</project>

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

宇宙超级无敌程序媛

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值