maven学习笔记(三)

pom.xml对于maven就好比build.xml对于ant。

pom.xml主要对源代码、配置文件、开发者信息和角色、问题追踪系统、组织信息、项目授权、项目url、项目的依赖关系等。

pom.xml大体的格式如下:

<project>

  <modelVersion>4.0.0</modelVersion>

  

  <!-- The Basics -->

  <groupId>...</groupId>

  <artifactId>...</artifactId>

  <version>...</version>

  <packaging>...</packaging>

  <dependencies>...</dependencies>

  <parent>...</parent>

  <dependencyManagement>...</dependencyManagement>

  <modules>...</modules>

  <properties>...</properties>

  <!-- Build Settings -->

  <build>...</build>

  <reporting>...</reporting>

  <!-- More Project Information -->

  <name>...</name>

  <description>...</description>

  <url>...</url>

  <inceptionYear>...</inceptionYear>

  <licenses>...</licenses>

  <organiztion>...</organiztion>

  <contributors>...</contributors>

  <!-- Environment Settings -->

  <issueManagement>...</issueManagement>

  <ciManagement>...</ciManagement>

  <mailingLists>...</mailingLists>

  <scm>...</scm>

  <prerequisites>...</prerequisites>

  <repositories>...</repositories>

  <pluginRepositories>...</pluginRespositories>

  <distributionManagement>...</distributionManagement>

  <profiles>...</profiles>

</project>

pom关系:主要是依赖,继承,合成

依赖关系

<dependencies>

  <dependency>

    <groupId>junit</groupId>

    <artifactId>junit</artifactId>

    <version>4.0</version>

    <type>jar</type>

    <scope>test</scope>

    <optional>true</optional>

  </dependency>

  ...

</dependencies>

继承关系

<parent>

  <groupId>...</groupId>

  <artifactId>...</artifactId>

  <version>...</version>

</parent>

聚合关系:可将多个maven项目聚合为一个大的项目

<project ...>

  <modelVersoin>4.0.0</modelVersion>

  <groupId>...</groupId>

  <artifactId>...</artifactId>

  <version>...</version>

  <modules>

    <module>my-project<module>

  </modules>

</project>

猜你喜欢

转载自tbmxp.iteye.com/blog/1956686