一、聚合
1.新建account项目,POM文件为
<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>com.iteye.xujava</groupId> <artifactId>account</artifactId> <version>1.0.0</version> <packaging>pom</packaging> <name>account</name> <modules> <module>account-email</module> <module>account-persist</module> </modules> </project>
2.在Eclipse中删除account-email,account-persist,将两个项目文件夹放在account文件夹下,在Eclipse重新引入这两个项目,修改account-persist中的service.properties内容为:persist.file=E:/mavenspace/account/account-persist/target/test-classes/persist-data.xml
3.运行mvn clean test
4.运行mvn clean install
二、继承
修改三个工和的POM文件
account的POM文件
<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>com.iteye.xujava</groupId> <artifactId>account</artifactId> <version>1.0.0</version> <packaging>pom</packaging> <name>Account</name> <modules> <module>account-email</module> <module>account-persist</module> </modules> <properties> <springframework.version>2.5.6</springframework.version> <junit.version>4.9</junit.version> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${springframework.version}</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency> </dependencies> </dependencyManagement> <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <configuration> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </pluginManagement> </build> </project>
account-email的POM文件
<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> <parent> <groupId>com.iteye.xujava</groupId> <artifactId>account</artifactId> <version>1.0.0</version> <!-- 当父项目的POM在上层时,其实可以不写relativePath --> <relativePath>../pom.xml</relativePath> </parent> <artifactId>account-email</artifactId> <name>Account Email</name> <properties> <javax.mail.version>1.4.1</javax.mail.version> <greenmail.version>1.3.1b</greenmail.version> </properties> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> </dependency> <dependency> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> <version>${javax.mail.version}</version> </dependency> <dependency> <groupId>com.icegreen</groupId> <artifactId>greenmail</artifactId> <version>${greenmail.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency> </dependencies> </project>
account persist中的POM文件
<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> <parent> <groupId>com.iteye.xujava</groupId> <artifactId>account</artifactId> <version>1.0.0</version> <relativePath>../pom.xml</relativePath> </parent> <artifactId>account-persist</artifactId> <name>Account Persist</name> <properties> <dom4j.version>1.6.1</dom4j.version> </properties> <dependencies> <dependency> <groupId>dom4j</groupId> <artifactId>dom4j</artifactId> <version>${dom4j.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency> </dependencies> <build> <testResources> <testResource> <directory>src/test/resources</directory> <filtering>true</filtering> </testResource> </testResources> </build> </project>
运行mvn clean test
运行mvn clean install
三、超级POM
超级POM位置在%M2_HOME%/lib/maven-model-builder-3.0.5.jar\org\apache\maven\model中,为pom-4.0.0.xml。
内容如下:
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- START SNIPPET: superpom --> <project> <modelVersion>4.0.0</modelVersion> <!-- 仓库 --> <repositories> <repository> <id>central</id> <name>Central Repository</name> <url>http://repo.maven.apache.org/maven2</url> <layout>default</layout> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <!-- 插件仓库 --> <pluginRepositories> <pluginRepository> <id>central</id> <name>Central Repository</name> <url>http://repo.maven.apache.org/maven2</url> <layout>default</layout> <snapshots> <enabled>false</enabled> </snapshots> <releases> <updatePolicy>never</updatePolicy> </releases> </pluginRepository> </pluginRepositories> <build> <!-- 项目主输出目录 --> <directory>${project.basedir}/target</directory> <!-- 项目主代码输出目录 --> <outputDirectory>${project.build.directory}/classes</outputDirectory> <!-- 最终构建的名称格式 --> <finalName>${project.artifactId}-${project.version}</finalName> <!-- 测试代码的输出目录 --> <testOutputDirectory>${project.build.directory}/test-classes</testOutputDirectory> <!-- 主源码目录 --> <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory> <!-- 脚本源码目录 --> <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory> <!-- 测试源码目录 --> <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory> <resources> <resource> <!-- 主资源目录 --> <directory>${project.basedir}/src/main/resources</directory> </resource> </resources> <testResources> <testResource> <!-- 测试资源目录 --> <directory>${project.basedir}/src/test/resources</directory> </testResource> </testResources> <pluginManagement> <!-- NOTE: These plugins will be removed from future versions of the super POM --> <!-- They are kept for the moment as they are very unlikely to conflict with lifecycle mappings (MNG-4453) --> <!-- 设定核心插件版本 --> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.3</version> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.2-beta-5</version> </plugin> <plugin> <artifactId>maven-dependency-plugin</artifactId> <version>2.1</version> </plugin> <plugin> <artifactId>maven-release-plugin</artifactId> <version>2.0</version> </plugin> </plugins> </pluginManagement> </build> <reporting> <outputDirectory>${project.build.directory}/site</outputDirectory> </reporting> <profiles> <!-- NOTE: The release profile will be removed from future versions of the super POM --> <profile> <id>release-profile</id> <activation> <property> <name>performRelease</name> <value>true</value> </property> </activation> <build> <plugins> <plugin> <inherited>true</inherited> <artifactId>maven-source-plugin</artifactId> <executions> <execution> <id>attach-sources</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> <plugin> <inherited>true</inherited> <artifactId>maven-javadoc-plugin</artifactId> <executions> <execution> <id>attach-javadocs</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> <plugin> <inherited>true</inherited> <artifactId>maven-deploy-plugin</artifactId> <configuration> <updateReleaseInfo>true</updateReleaseInfo> </configuration> </plugin> </plugins> </build> </profile> </profiles> </project> <!-- END SNIPPET: superpom -->
四、反应堆
相关推荐
一个简单的maven聚合,继承示例。parent为父目录,account-email,account-persist为子项目,继承了parent的pom.xml文件
在javaweb高速发展的今天,我们软件设计人员往往会用很多种...Maven有很好的依赖管理系统(Dependency Management System)和项目生命周期的管理(Project Leftcycle),而其中的依赖管理是本文阐述和做出实例的重点。
这是一个maven依赖+继承+聚合的小例子,用来参考和学习maven
该资源包含了一个maven聚合和继承的简单demo,可以参考博客http://blog.csdn.net/mockingbirds/article/details/47374127
Maven聚合和继承 #资源达人分享计划 # 技术文档
这里是maven继承与聚合代码。
maven项目,主要是一些配置,如聚合和继承以及插件.私服等,项目按模块区分,多个子项目继承parent
Maven的聚合与继承DEMO(以及前后端分离) 讲解文章:https://blog.csdn.net/Bof_jangle/article/details/106185213
利用maven构建项目,ssh简易框架,利用了聚合和继承
通过Maven的聚合和继承特性创建复杂的多模块项目的简单演示,详细介绍见http://blog.csdn.net/autfish/article/details/51939515
maven 依赖,聚合,继承,插件运行,已经说明的简单小案例
本资源主要内容: Maven安装、配置、仓库、POM坐标系、Maven工程、继承与聚合
演示如何利用maven进行模块分组、依赖集中处理、依赖约定处理、继承使用。。。
maven总结笔记-继承和聚合
用于对Maven聚合继承项目的版本号进行便捷变更的工具 在使用RPC框架的微服务架构中,为了让服务消费者实现像调用本地方法一样的透明的通过网络进行RPC,服务提供者一般会提供立面jar用于服务消费者集成并通过动态...
Maven3_05_maven的聚合和继承 Maven3_06_复习maven的基本内容 Maven3_07_nexus的介绍和安装 Maven3_08_nexus的配置 Maven3_09_发布项目到nexus中 Maven3_10_生命周期和插件简介 Maven3_11_插件基础 Maven3_12_插件的...
NULL 博文链接:https://dannyhz.iteye.com/blog/2249427
第8章:聚合和继承/8.4 聚合与继承的关系 第8章:聚合和继承/8.5 约定优于配置 第8章:聚合和继承/8.6 反应堆/8.6.1 反应堆的构建顺序 第8章:聚合和继承/8.6 反应堆/8.6.2 剪切反应堆 第9章:使用Nexus创建私服/9.2...
基于Maven搭建Spring+Mybatis的项目,包含Maven聚合和继承、Mybatis增删改查和分页、SpringMVC开发及使用拦截器检查登录等知识点。详细介绍 http://blog.csdn.net/autfish/article/details/52037354
今天小编就为大家分享一篇关于Maven的聚合(多模块)和Parent继承,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧