创建项目

xxx - 继承自testDep.PPP

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>testDep.XXX</groupId>
<artifactId>xxx</artifactId>
<packaging>jar</packaging> <name>xxx</name>
<url>http://maven.apache.org</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> <parent>
<groupId>testDep.PPP</groupId>
<artifactId>ppp</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
</project>

yyy - 继承自testDep.PPP

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>testDep.YYY</groupId>
<artifactId>yyy</artifactId>
<packaging>jar</packaging> <name>yyy</name>
<url>http://maven.apache.org</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> <parent>
<groupId>testDep.PPP</groupId>
<artifactId>ppp</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
</project>

zzz - 在zzz中聚合xxx和yyy

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>testDep.ZZZ</groupId>
<artifactId>zzz</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging> <name>zzz</name>
<url>http://maven.apache.org</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<modules>
<module>../xxx</module>
<module>../yyy</module>
</modules>
</project>

ppp - 父项目

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>testDep.PPP</groupId>
<artifactId>ppp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging> <name>ppp</name>
<url>http://maven.apache.org</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>3.8.1</junit.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>

验证

ppp执行clean install

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ppp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ ppp ---
[INFO] Deleting D:\Anliven-Running\Zen\EclipseProjects\ppp\target
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ ppp ---
[INFO] Installing D:\Anliven-Running\Zen\EclipseProjects\ppp\pom.xml to D:\DownLoadFiles\apache-maven-repo\testDep\PPP\ppp\0.0.1-SNAPSHOT\ppp-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.578 s
[INFO] Finished at: 2017-10-24T16:43:09+08:00
[INFO] Final Memory: 9M/309M
[INFO] ------------------------------------------------------------------------

xxx执行clean install

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building xxx 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ xxx ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Anliven-Running\Zen\EclipseProjects\xxx\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ xxx ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ xxx ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Anliven-Running\Zen\EclipseProjects\xxx\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ xxx ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ xxx ---
[INFO] Surefire report directory: D:\Anliven-Running\Zen\EclipseProjects\xxx\target\surefire-reports -------------------------------------------------------
T E S T S
-------------------------------------------------------
Running testDep.XXX.xxx.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ xxx ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ xxx ---
[INFO] Installing D:\Anliven-Running\Zen\EclipseProjects\xxx\target\xxx-0.0.1-SNAPSHOT.jar to D:\DownLoadFiles\apache-maven-repo\testDep\XXX\xxx\0.0.1-SNAPSHOT\xxx-0.0.1-SNAPSHOT.jar
[INFO] Installing D:\Anliven-Running\Zen\EclipseProjects\xxx\pom.xml to D:\DownLoadFiles\apache-maven-repo\testDep\XXX\xxx\0.0.1-SNAPSHOT\xxx-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.520 s
[INFO] Finished at: 2017-10-24T16:47:36+08:00
[INFO] Final Memory: 11M/245M
[INFO] ------------------------------------------------------------------------

zzz 执行clean install

从输出日志可以看到进行了3次构建,并安装到本地仓库中:

Building xxx 0.0.1-SNAPSHOT

Building yyy 0.0.1-SNAPSHOT

Building zzz 0.0.1-SNAPSHOT

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] xxx
[INFO] yyy
[INFO] zzz
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building xxx 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ xxx ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Anliven-Running\Zen\EclipseProjects\xxx\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ xxx ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ xxx ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Anliven-Running\Zen\EclipseProjects\xxx\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ xxx ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ xxx ---
[INFO] Surefire report directory: D:\Anliven-Running\Zen\EclipseProjects\xxx\target\surefire-reports -------------------------------------------------------
T E S T S
-------------------------------------------------------
Running testDep.XXX.xxx.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ xxx ---
[INFO] Building jar: D:\Anliven-Running\Zen\EclipseProjects\xxx\target\xxx-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ xxx ---
[INFO] Installing D:\Anliven-Running\Zen\EclipseProjects\xxx\target\xxx-0.0.1-SNAPSHOT.jar to D:\DownLoadFiles\apache-maven-repo\testDep\XXX\xxx\0.0.1-SNAPSHOT\xxx-0.0.1-SNAPSHOT.jar
[INFO] Installing D:\Anliven-Running\Zen\EclipseProjects\xxx\pom.xml to D:\DownLoadFiles\apache-maven-repo\testDep\XXX\xxx\0.0.1-SNAPSHOT\xxx-0.0.1-SNAPSHOT.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building yyy 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ yyy ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Anliven-Running\Zen\EclipseProjects\yyy\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ yyy ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ yyy ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Anliven-Running\Zen\EclipseProjects\yyy\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ yyy ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ yyy ---
[INFO] Surefire report directory: D:\Anliven-Running\Zen\EclipseProjects\yyy\target\surefire-reports -------------------------------------------------------
T E S T S
-------------------------------------------------------
Running testDep.YYY.yyy.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.008 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ yyy ---
[INFO] Building jar: D:\Anliven-Running\Zen\EclipseProjects\yyy\target\yyy-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ yyy ---
[INFO] Installing D:\Anliven-Running\Zen\EclipseProjects\yyy\target\yyy-0.0.1-SNAPSHOT.jar to D:\DownLoadFiles\apache-maven-repo\testDep\YYY\yyy\0.0.1-SNAPSHOT\yyy-0.0.1-SNAPSHOT.jar
[INFO] Installing D:\Anliven-Running\Zen\EclipseProjects\yyy\pom.xml to D:\DownLoadFiles\apache-maven-repo\testDep\YYY\yyy\0.0.1-SNAPSHOT\yyy-0.0.1-SNAPSHOT.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building zzz 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ zzz ---
[INFO] Installing D:\Anliven-Running\Zen\EclipseProjects\zzz\pom.xml to D:\DownLoadFiles\apache-maven-repo\testDep\ZZZ\zzz\0.0.1-SNAPSHOT\zzz-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] xxx ................................................ SUCCESS [ 2.282 s]
[INFO] yyy ................................................ SUCCESS [ 0.351 s]
[INFO] zzz ................................................ SUCCESS [ 0.007 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.819 s
[INFO] Finished at: 2017-10-24T16:43:49+08:00
[INFO] Final Memory: 12M/309M
[INFO] ------------------------------------------------------------------------

Maven - 实例-6-聚合与继承的更多相关文章

  1. maven项目的聚合与继承

    maven项目的聚合与继承: 一.聚合 如果我们想一次构建多个项目模块,那我们就需要对多个项目模块进行聚合 1.1.聚合配置代码 1 <modules> 2 <module>模 ...

  2. Maven学习总结——聚合与继承

    一.聚合 如果我们想一次构建多个项目模块,那我们就需要对多个项目模块进行聚合 1.1.聚合配置代码 1 <modules> 2 <module>模块一</module&g ...

  3. maven 依赖、聚合和继承 (转)

    Maven 插件和仓库 Maven 本质上是一个插件框架,它的核心并不执行任何具体的构建任务,仅仅定义了抽象的生命周期,所有这些任务都交给插件来完成的.每个插件都能完成至少一个任务,每个任务即是一个功 ...

  4. maven学习(十一)——maven中的聚合与继承

    一.聚合 如果我们想一次构建多个项目模块,那我们就需要对多个项目模块进行聚合 1.1.聚合配置代码 <modules> <module>模块一</module> & ...

  5. Java-Maven(七):Eclipse中Maven依赖、聚合、继承特性

    之前通过学习了解,maven集成到eclipse中的如何创建项目,以及maven命令插件在eclipse中安装后的用法.那么接下来我们将会学习一些maven在项目中的一些特性,及如何使用. Maven ...

  6. (五)Maven中的聚合和继承

    一.为什么要聚合? 定义:我们在开发过程中,创建了2个以上的模块,每个模块都是一个独立的maven project,在开始的时候我们可以独立的编译和测试运行每个模块,但是随着项目的不断变大和复杂化,我 ...

  7. Maven专题2——聚合与继承

    聚合 聚合模块的<packaging>元素为pom 聚合模块通过<modules>元素标识自己的子模块,每个子模块对应了一个module元素 module元素中指定的是子模块所 ...

  8. Maven聚合与继承的实例讲解(二)

    继续上一节讲Maven的内容,我们这个节继续讲Maven继承和聚合的其他内容.    现在我们新建一个实例来测试Maven有关于聚合的部分     测试开始 一.建立以pom为packaging的项目 ...

  9. (十四)Maven聚合与继承

    1.Maven聚合 我们在平时的开发中,项目往往会被划分为好几个模块,比如common公共模块.system系统模块.log日志模块.reports统计模块.monitor监控模块等等.这时我们肯定会 ...

随机推荐

  1. intellij idea 配置gitlab ssh key

    1 安装git,登录官网https://www.git-scm.com/download/ ,选择相应系统版本,下载后安装好. 公司网慢的可以用第三方的软件管家下载. 2 打开git bash,不需要 ...

  2. IOC 和DI(转载)

    IOC 是什么? Ioc—Inversion of Control,即“控制反转”,不是什么技术,而是一种设计思想.在Java开发中,Ioc意味着将你设计好的对象交给容器控制,而不是传统的在你的对象内 ...

  3. Python开发【第七篇】:面向对象二

    字段 class Foo:     #静态字段(保存在类中)     CC = 123       def __init__(self):         #普通字段(保存在对象中)          ...

  4. 手动添加jar包到本地maven仓库

    我们都知道使用maven管理jar包的时候,我们需要到远程仓库下载相关的jar包到本地仓库,但是如果远程仓库没有这个jar包呢?这时候我们就需要手动将jar包添加到本地仓库. 起因是我想用百度的富文本 ...

  5. [leetcode]21. Merge Two Sorted Lists合并两个链表

    Merge two sorted linked lists and return it as a new list. The new list should be made by splicing t ...

  6. Linux学习小记(1)

    学习Linux,进行阶段性总结,权当笔记方便日后翻阅和查看. 在此特别推荐peida的博客,他的有关Linux的理解个人感觉深入浅出,很适合入门的小白来理解和学习. 说一说针对IP的修改,ifconf ...

  7. 201771010142 张燕 Java的基本程序设计结构第二周学习总结

    第三章 Java的基本程序设计结构 第一部分 理论知识学习部分 一 基本知识: 1.标识符:由字母.下划线,美元符号和数字组成,第一个符号不能为数字,可以用作类名.变量名.方法名.数组名和文件名等. ...

  8. RDS MySQL InnoDB 锁等待和锁等待超时的处理

    https://help.aliyun.com/knowledge_detail/41705.html 1. Innodb 引擎表行锁等待和等待超时发生的场景 2.Innodb 引擎行锁等待情况的处理 ...

  9. 标准时间转YYYY-MMM-DD

    // 时间处理 formatDate(date, fmt) { let o = { 'M+': date.getMonth() + 1, //月份 'd+': date.getDate(), //日 ...

  10. base operand of '->' has non-pointer type 'const Comple

    base operand of '->' has non-pointer type 'const Comple ->操作符前面的操作数类型不是指针类型 错误原因 函数(&对象) { ...