pom.xml解释

modelVersion 制定当前pom的版本

groupId 反写公司网址+项目名
artifactId 项目名+模块名
version 版本号
packaging 打包方式

name 项目描述名
url 项目地址
description 项目描述

dependencies 依赖列表
    dependency
        groupId
        artifactId
        version
        scope 依赖范围
        optional 设置依赖是否可选
        exclusions 排除依赖传递列表
            exclusion
                groupId
                artifactId
                version

<dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <!-- 只在编译和测试中运行 -->
            <scope>provided</scope>
        </dependency>
    </dependencies>

scope 依赖范围
参数:
compile 默认的范围,编译测试运行都有效
provided 在编译和测试有效
runtime 在测试和运行时有效
test 只在测试时有效
system 与本机系统相关联,可移植性差
import 导入的范围,只使用在dependencyManagement中,表示从其他的pom中导入dependecy的配置

依赖继承:A继承B,B继承C。则A中会存放B和C的jar,但可以用exclusion排除C的jar

graph LR
A-->B
B-->C

依赖冲突:短路优先;若路径长度相同,则谁先声明,先解析谁

dependencyManagement 依赖管理,声明依赖(并不会在该项目中使用)
    dependencies
        dependency
build 构建设置
    plugins 插件列表
        plugin
            groupId
            artifactId
            version
            executions
                execution
                    phase
                    goals
                        goal

<build>
    <finalName>WebDemo</finalName>
    <plugins>
        <plugin>            
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <port>8888</port>
                <uriEncoding>UTF-8</uriEncoding>
                <url>http://localhost:8888/WebDemo/</url>
                <server>tomcat6</server>
            </configuration>
            <executions>
                <execution>
                    <!-- 在打包成功后使用tomcat:run来运行tomcat服务 -->
                    <phase>package</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

parent 继承

聚合

modules 模块列表
module

继承

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值