Maven的pom.xml文件结构之基本配置parent和继承结构[转]

1.Maven项目的继承

Maven项目之间不仅存在多模块的聚合关系,而且Maven项目之间还可以存在相互继承的关系。

Maven项目之间的继承关系通过<parent>表示,在子Maven项目的POM中配置示例如下:

  1. <parent>  
  2.   <groupId>com.mycompany.jcat</groupId>  
  3.   <artifactId>jcat-bundle</artifactId>  
  4.   <version>2.0</version>  
  5.   <relativePath>../jcat-bundle</relativePath>  
  6. </parent>  
说明:给出被继承的父项目的具体信息。

其中的relativePath给出父项目相对于子项目的路径,这样在构件子项目时首先从该相对路径查找父项目,如果没有才会从本地库或进而远程库中查找父项目。


2.在子项目中,能够继承父项目的如下配置:

  • dependencies
  • developers
  • contributors
  • plugin lists
  • reports lists
  • plugin executions with matching ids
  • plugin configuration

3.Maven的Super POM

类似于Java中的java.lang.Object类,所有Java类都继承自该类。在Maven中也存在一个特殊的POM,被称为Super POM。任何Maven项目的POM都继承自Super POM。

在Super POM中,设置如下:

  • Maven的central库
  • Maven的central插件库
  • build的基本参数和4个插件(maven-assembly-plugin、maven-release-plugin)
  • reporting的基本目录
  • 一个profile(id=release-profile)
http://blog.csdn.net/taiyangdao/article/details/52357300
原文地址:https://www.cnblogs.com/jimcsharp/p/8574661.html