文章目录
  1. 1. 一、基本坐标信息
  2. 2. 二、其他信息
  3. 3. 三、依赖信息

一、基本坐标信息

  • 主项目标识 < groupId > :
    1
    <groupId>反写的公司地址+项目名</groupId>

eg. com.cqupt.spider

  • 模块标识 < artifactId > :
    1
    <artifactId>项目名+模块名</artifactId>

eg. spider.demo

  • 版本号 < version > :
    1
    <version>大.分支.小+(版本)</version>

eg. 版本号 1.3.2-SNAPSHOT

  • 基本版本信息:
    1:大版本号
    3:分支版本号
    2:小版本号
  • 版本类型:
    SNAPSHOT:快照
    ALPHA:内部测试
    BETA:公测
    RELEASE:稳定
    GA:正式发布
    • 打包方式 < packaging > :
      1
      <packaging>包的类型后缀</packaging>

默认为jar,此外还有war、zip、pom等

二、其他信息

  • 项目描述名 < name >
  • 项目地址 < url >
  • 项目描述 < description >
  • 开发人员列表 < developers >
  • 许可证信息(如开源许可等) < licenses >
  • 组织人员信息 < organization >

三、依赖信息

  • 基本依赖信息

    1
    2
    3
    4
    5
    6
    7
    <dependencies>
    <dependency>
    <groupId></groupId>
    <artifactId></artifactId>
    <version></version>
    </dependency>
    </dependencies>
  • 其他依赖信息

    • 打包类型 < type > :
      对应于依赖项目的packaging类型,默认为jar
    • 依赖范围 < scope > :
      表示依赖项目的作用范围,可选类型如下:
      • compile : 默认范围,编译测试运行均有效
      • provided : 编译和测试时有效
      • runtime : 测试和运行时有效
      • test : 仅在测试时有效
      • system : 类似provided,需要在本地提供jar包,可移植性较差
      • import : 导入的范围,表示从其他pom中导入dependency的配置;仅在dependencyManagement中使用
    • 是否可选 < optional > :
      当该项目本身作为其他项目的依赖时,标记为可选;默认为false
    • 依赖排除 < exclusions > :
      若项目A依赖于项目B,项目B依赖于项目C,但A不想依赖C,就可以用exclusion排除C;就比如说对A:

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      <dependencies>
      <dependency>
      <groupId>com.cqupt.mavenTest</groupId>
      <artifactId>projectB</artifactId>
      <version>1.0-SNAPSHOT</version>
      <exclusions>
      <exclusion>
      <groupId>com.cqupt.mavenTest</groupId>
      <artifactId>projectC</artifactId>
      </exclusion>
      </exclusions>
      </dependency>
      </dependencies>
    • 依赖管理 < dependencyManagement > :
      主要放在父模块中,供子模块继承用的;
      另外:dependencyManagement里只是声明依赖,并不实现引入,因此子项目需要显式声明要继承的依赖。

      1
      2
      3
      4
      5
      <dependencyManagement>
      <dependencies>
      <dependency></dependency>
      </dependencies>
      </dependencyManagement>
    • 插件列表 < plugins > :
      其实是放在build里的啦,build才是跟上面平行的,但是这个比较有用, 就单独拿出来讲啦

      1
      2
      3
      4
      5
      6
      7
      8
      9
      <build>
      <plugins>
      <plugin>
      <groupId></groupId>
      <artifactId></artifactId>
      <version></version>
      </plugin>
      </plugins>
      </build>
    • 父模块指定 < parent > :
      在子模块中指定要继承的父模块,注意继承的是整个模块而不是不是其中的某个依赖这样

      1
      2
      3
      4
      5
      <parent>
      <groupId>com.cqupt.parentTest</groupId>
      <artifactId>projectX</artifactId>
      <version>1.0-SNAPSHOT</version>
      </parent>
    • 多模块管理 < modules > :
      用在父模块中,可对各子模块进行多模块的统一管理

      1
      2
      3
      4
      5
      <modules>
      <module>子模块A的artifactId</module>
      <module>子模块B的artifactId</module>
      <module>子模块C的artifactId</module>
      </modules>
文章目录
  1. 1. 一、基本坐标信息
  2. 2. 二、其他信息
  3. 3. 三、依赖信息