对于 Maven3,超级 POM 在文件 %MAVEN_HOME%/lib/maven-model-builder-x.x.x.jar 中的 org/apache/maven/model/pom-4.0.0.xml 路径下、

对于 Maven2,超级 POM 在文件 %MAVEN_HOME%/lib/maven-x.x.x-uber.jar 中的 org/apache/maven/project/pom-4.0.0.xml 目录下。

这里的 x.x.x 表示 Maven 的具体版本。

对于使用java的人而言,继承这个词大家应该都不陌生。要继承pom就需要有一个父pom,在Maven中定义了超级pom.xml,任何没有申明自己父pom.xml的pom.xml都将默认继承自这个超级pom.xml。

先来看一下这个超级pom.xml的定义:

Xml代码  
  1. <project>
  2. <modelVersion>4.0.0</modelVersion>
  3. <name>Maven Default Project</name>
  4. <repositories>
  5. <repository>
  6. <id>central</id>
  7. <name>Maven Repository Switchboard</name>
  8. <layout>default</layout>
  9. <url>http://repo1.maven.org/maven2</url>
  10. <snapshots>
  11. <enabled>false</enabled>
  12. </snapshots>
  13. </repository>
  14. </repositories>
  15. <pluginRepositories>
  16. <pluginRepository>
  17. <id>central</id>
  18. <name>Maven Plugin Repository</name>
  19. <url>http://repo1.maven.org/maven2</url>
  20. <layout>default</layout>
  21. <snapshots>
  22. <enabled>false</enabled>
  23. </snapshots>
  24. <releases>
  25. <updatePolicy>never</updatePolicy>
  26. </releases>
  27. </pluginRepository>
  28. </pluginRepositories>
  29. <build>
  30. <directory>${project.basedir}/target</directory>
  31. <outputDirectory>${project.build.directory}/classes</outputDirectory>
  32. <finalName>${project.artifactId}-${project.version}</finalName>
  33. <testOutputDirectory>${project.build.directory}/test-classes</testOutputDirectory>
  34. <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
  35. <!-- TODO: MNG-3731 maven-plugin-tools-api < 2.4.4 expect this to be relative... -->
  36. <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory>
  37. <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
  38. <resources>
  39. <resource>
  40. <directory>${project.basedir}/src/main/resources</directory>
  41. </resource>
  42. </resources>
  43. <testResources>
  44. <testResource>
  45. <directory>${project.basedir}/src/test/resources</directory>
  46. </testResource>
  47. </testResources>
  48. <pluginManagement>
  49. <plugins>
  50. <plugin>
  51. <artifactId>maven-antrun-plugin</artifactId>
  52. <version>1.3</version>
  53. </plugin>
  54. <plugin>
  55. <artifactId>maven-assembly-plugin</artifactId>
  56. <version>2.2-beta-2</version>
  57. </plugin>
  58. <plugin>
  59. <artifactId>maven-clean-plugin</artifactId>
  60. <version>2.2</version>
  61. </plugin>
  62. <plugin>
  63. <artifactId>maven-compiler-plugin</artifactId>
  64. <version>2.0.2</version>
  65. </plugin>
  66. <plugin>
  67. <artifactId>maven-dependency-plugin</artifactId>
  68. <version>2.0</version>
  69. </plugin>
  70. <plugin>
  71. <artifactId>maven-deploy-plugin</artifactId>
  72. <version>2.4</version>
  73. </plugin>
  74. <plugin>
  75. <artifactId>maven-ear-plugin</artifactId>
  76. <version>2.3.1</version>
  77. </plugin>
  78. <plugin>
  79. <artifactId>maven-ejb-plugin</artifactId>
  80. <version>2.1</version>
  81. </plugin>
  82. <plugin>
  83. <artifactId>maven-install-plugin</artifactId>
  84. <version>2.2</version>
  85. </plugin>
  86. <plugin>
  87. <artifactId>maven-jar-plugin</artifactId>
  88. <version>2.2</version>
  89. </plugin>
  90. <plugin>
  91. <artifactId>maven-javadoc-plugin</artifactId>
  92. <version>2.5</version>
  93. </plugin>
  94. <plugin>
  95. <artifactId>maven-plugin-plugin</artifactId>
  96. <version>2.4.3</version>
  97. </plugin>
  98. <plugin>
  99. <artifactId>maven-rar-plugin</artifactId>
  100. <version>2.2</version>
  101. </plugin>
  102. <plugin>
  103. <artifactId>maven-release-plugin</artifactId>
  104. <version>2.0-beta-8</version>
  105. </plugin>
  106. <plugin>
  107. <artifactId>maven-resources-plugin</artifactId>
  108. <version>2.3</version>
  109. </plugin>
  110. <plugin>
  111. <artifactId>maven-site-plugin</artifactId>
  112. <version>2.0-beta-7</version>
  113. </plugin>
  114. <plugin>
  115. <artifactId>maven-source-plugin</artifactId>
  116. <version>2.0.4</version>
  117. </plugin>
  118. <plugin>
  119. <artifactId>maven-surefire-plugin</artifactId>
  120. <version>2.4.3</version>
  121. </plugin>
  122. <plugin>
  123. <artifactId>maven-war-plugin</artifactId>
  124. <version>2.1-alpha-2</version>
  125. </plugin>
  126. </plugins>
  127. </pluginManagement>
  128. </build>
  129. <reporting>
  130. <outputDirectory>${project.build.directory}/site</outputDirectory>
  131. </reporting>
  132. <profiles>
  133. <profile>
  134. <id>release-profile</id>
  135. <activation>
  136. <property>
  137. <name>performRelease</name>
  138. <value>true</value>
  139. </property>
  140. </activation>
  141. <build>
  142. <plugins>
  143. <plugin>
  144. <inherited>true</inherited>
  145. <groupId>org.apache.maven.plugins</groupId>
  146. <artifactId>maven-source-plugin</artifactId>
  147. <executions>
  148. <execution>
  149. <id>attach-sources</id>
  150. <goals>
  151. <goal>jar</goal>
  152. </goals>
  153. </execution>
  154. </executions>
  155. </plugin>
  156. <plugin>
  157. <inherited>true</inherited>
  158. <groupId>org.apache.maven.plugins</groupId>
  159. <artifactId>maven-javadoc-plugin</artifactId>
  160. <executions>
  161. <execution>
  162. <id>attach-javadocs</id>
  163. <goals>
  164. <goal>jar</goal>
  165. </goals>
  166. </execution>
  167. </executions>
  168. </plugin>
  169. <plugin>
  170. <inherited>true</inherited>
  171. <groupId>org.apache.maven.plugins</groupId>
  172. <artifactId>maven-deploy-plugin</artifactId>
  173. <configuration>
  174. <updateReleaseInfo>true</updateReleaseInfo>
  175. </configuration>
  176. </plugin>
  177. </plugins>
  178. </build>
  179. </profile>
  180. </profiles>
  181. </project>

对于一个pom.xml来说有几个元素是必须定义的,一个是project根元素,然后就是它里面的modelVersion、groupId、artifactId和version。由上面的超级pom.xml的内容我们可以看到pom.xml中没有groupId、artifactId和version的定义,所以我们在建立自己的pom.xml的时候就需要定义这三个元素。和java里面的继承类似,子pom.xml会完全继承父pom.xml中所有的元素,而且对于相同的元素,一般子pom.xml中的会覆盖父pom.xml中的元素,但是有几个特殊的元素它们会进行合并而不是覆盖。这些特殊的元素是:

Ø  dependencies

Ø  developers

Ø  contributors

Ø  plugin列表,包括plugin下面的reports

Ø  resources

参考:

1、http://blog.csdn.net/tounaobun/article/details/8958125

2、http://blog.csdn.net/haojiahj/article/details/49964919

maven的超级pom的更多相关文章

  1. 学习笔记——Maven超级POM

    2014-07-04:更新如何在安装程序中找到超级pom文件.Maven有一个超级POM,所有的POM均继承此文件.你可以使用解压工具打开jar文件$M2_HOME/lib/maven-model-b ...

  2. maven 超级pom位置、maven命令、构件、下载位置、手动打包位置、中央仓库ip

    1.超级pom位置 ----> 解压M2_HOME/lib/maven-model-builder-3.5.4.jar 2.运行maven 命令实际上是运行了 java 命令,因为maven插件 ...

  3. maven 仓库配置 pom中repositories属性

    文章转自http://blog.csdn.net/zlgydx/article/details/51130627 什么是Maven仓库在不用Maven的时候,比如说以前我们用Ant构建项目,在项目目录 ...

  4. maven常用插件pom配置

    一.问题描述: 部署一个maven打包项目时,jar包,依赖lib包全部手动上传至服务器,然后用maven部署报错:Exception in thread "main" java. ...

  5. eclipse加载maven工程提示pom.xml无法解析org.apache.maven.plugins:maven-resources-plugin:2.4.3解决方案

    pom文件提示信息: Failure to transfer org.apache.maven.plugins:maven-resources-plugin:pom:2.4.3 from http:/ ...

  6. (转)maven配置之pom.xml配置

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  7. Maven系列一pom.xml 配置详解

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  8. 【转】maven核心,pom.xml详解

    感谢如下博主: http://www.cnblogs.com/qq78292959/p/3711501.html maven核心,pom.xml详解 什么是pom?    pom作为项目对象模型.通过 ...

  9. maven编译设置pom.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

随机推荐

  1. (转)SpringMVC学习(八)——SpringMVC中的异常处理器

    http://blog.csdn.net/yerenyuan_pku/article/details/72511891 SpringMVC在处理请求过程中出现异常信息交由异常处理器进行处理,自定义异常 ...

  2. 关于JDBC访问存储过程的问题

    最近开发一个应用,需要调用一个入参为List的存储过程. 存储过程为: proc_test(p1 OUT Number, p2 IN Number, p3 IN TAB_CUSTOMER); 这个Li ...

  3. iview table 勾选当前行代码 data key _checked: true

    给 data 项设置特殊 key _checked: true 可以默认选中当前项

  4. python json.loads json.dumps的区别

    json.loads() 是将字符串传化为字典 json.dumps () 是将字典转化为字符串 >>> dict = "{8:'bye', 'you':'coder'}& ...

  5. 苹果平台上的媒体流播放技术HLS

    近日在和朋友聊起媒体流的服务器端实时转码技术的时候,发现苹果的各种终端上的视频播放并未使用常见的基于UDP的RTSP/RTP,而强制使用了Http Live Stream技术,这里稍稍总结了如下. 苹 ...

  6. 深入理解JavaScript的设计模式

    使用适当的设计模式可以帮助你编写更好.更易于理解的代码.这样的代码也更容易维护.但是,重要的是不要过度使用它们.在使用设计模式之前,你应该仔细考虑你的问题是否符合设计模式. 当你开始一个新的项目时,你 ...

  7. tornado框架基础01-路由简介

    tornado 小而精 Django 大而全 Web框架 Tornado是一个由Python开发的Web框架 Web服务 利用Tornado,可以快速搭建和一个高性能的Web服务 非阻塞 Tornad ...

  8. Django框架基础知识06-模型基础

    1.数据库的连接配置 django 连接mysql的配置流程: 安装 pymysql pip install pymysql 创建数据库用户 有创建数据库权限的用户 创建数据库 crm 修改配置 se ...

  9. Python进阶之网络编程

    网络通信 使用网络的目的 把多方链接在一起,进行数据传递: 网络编程就是,让不同电脑上的软件进行数据传递,即进程间通信: ip地址 ip地址概念和作用 IP地址是什么:比如192.168.1.1 这样 ...

  10. 一直被用错的6种SQL 错误用法

    一直被用错的6种SQL 错误用法 1.LIMIT 语句 2.隐式转换 3.关联更新.删除 4.EXISTS语句 5.条件下推 6.提前缩小范围 sql语句的执行顺序: FROM ON JOIN WHE ...