创建coffee-parent项目

New->Maven Project

创建coffee-web项目

右键coffee-parent项目->New->Project...

注意:需要在src/main/webapp下创建WEB-INF文件夹,以及在WEB-INF下创建web.xml。

创建coffee-api项目

右键coffee-parent项目->New->Project...

注意:前面步骤同coffee-web项目

项目结构:

pom.xml文件

coffee-parent项目的pom.xml:

<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.coffee</groupId>
<artifactId>coffee-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>coffee-web</module>
<module>coffee-api</module>
</modules> <!-- 管理依赖,供子项目选择使用 -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.coffee</groupId>
<artifactId>coffee-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement> <build>
<!-- 配置使用jdk1.7编译,所有子项目都会继承此配置,如需配置为子项目可选继承,则需要配置到 pluginManagement下-->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

coffee-web项目的pom.xml:

<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.coffee</groupId>
<artifactId>coffee-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>coffee-web</artifactId>
<packaging>war</packaging> <!-- coffee-web依赖coffee-api,无需配置version,使用父项目coffee-parent中配置的version-->
<dependencies>
<dependency>
<groupId>com.coffee</groupId>
<artifactId>coffee-api</artifactId>
</dependency>
</dependencies>
</project>

coffee-api项目的pom.xml:

<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.coffee</groupId>
<artifactId>coffee-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>coffee-api</artifactId>
</project>

构建

右键coffee-parent项目->Run As->Maven install

构建成功:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for coffee-parent 0.0.1-SNAPSHOT:
[INFO]
[INFO] coffee-parent ...................................... SUCCESS [ 0.754 s]
[INFO] coffee-api ......................................... SUCCESS [ 2.085 s]
[INFO] coffee-web ......................................... SUCCESS [ 0.888 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.980 s
[INFO] Finished at: 2019-06-03T21:44:43+08:00
[INFO] ------------------------------------------------------------------------

Maven多模块构建实例的更多相关文章

  1. maven - 多模块构建

    使用idea创建maven项目 点击next输入GroupId和ArtifactId 点击next创建项目,新建项目结构如下 修改demo打包方式为pom 按层级拆分创建模块model,server, ...

  2. Maven高级:01.maven分模块构建&&02.私服的应用

    IntelliJ IDEA 2018.3.6 x64 07 Maven高级:01.maven分模块构建(上) 07 Maven高级:01.maven分模块构建(中) 07 Maven高级:01.mav ...

  3. gradle_学习_02_gradle多模块构建实例

    一.前言 二.多模块构建 1.工程结构 父工程:weixin-service 子模块:weixin-gz weixin-qy 2.父工程 weixin-service (1)build.gradle ...

  4. 谈谈maven多模块

    记得在校的时候,通常用的比较多是动态web工程,动态web工程导入最多就是jar包,这些jar包需要自己手动复制粘贴放入lib目录下,然后build path,有的IDE会自动build path有的 ...

  5. maven多模块项目构建

    描述 一个大的企业级项目通常跨越了数十万行代码,牵涉了数十或数百软件人员的努力.如果开发者在同一个项目下开   发,那么项目的管理.构建将会变得很难控制.因此设计人员会将项目划分为多个模块,多个模块独 ...

  6. SpringBoot+Maven 多模块项目的构建、运行、打包

    SpringBoot+Maven 多模块项目的构建.运行.打包 https://blog.csdn.net/zekeTao/article/details/79413919

  7. Jenkins构建Maven多模块项目时,单独编译子模块,并且不触发构建其它模块

    一.Jenkins构建Maven多模块项目时,单独编译子模块 配置: 1.Root POM指向父pom.xml 2.Goals and options指定构建模块的参数:mvn -pl jsoft-w ...

  8. SSM001/构建maven多模块项目

    一.Idea构建maven多模块项目 1.创建maven项目--创建父模块 [1].File->New->Module... [2].点击next,填写:GroupId,ArtifactI ...

  9. springboot的maven多模块项目架构微服务搭建——构建多模块项目(依赖方式)

    总想对微服务架构做一个小小的总结,不知如何下手,最近觉得还是从搭建微服务的过程来入手,对于springboot的maven项目从构建多模块架构进而衍化为常用的微服务架构来做个记录吧. 首先,创建多个s ...

随机推荐

  1. 5 Ways to Send Email From Linux Command Line

    https://tecadmin.net/ways-to-send-email-from-linux-command-line/ We all know the importance of email ...

  2. the algebra of modulo-2 sums disk failure recovery

    x=y x_+_y=0 The bit in any position is the modulo-2 sum of all the bits in the corresponding positio ...

  3. 对于URL中文和特殊字符的处理方法

    1.中文的处理方法 NSString* string1 = @"https://www.cloudsafe.com/文件夹"; NSString* string2 = [strin ...

  4. Tomcat Session Clustering

    搭建 Tomcat 集群需要解决很多的问题,其中之一就是要解决 Session 共享问题.小规模集群可以使用 Tomcat 提供的 Session Clustering 来解决. For the im ...

  5. indexDB操作(部分方法不太会使用)

    <script type="text/javascript"> //打开数据库 function openDB(name,version){ var version = ...

  6. [HTML & CSS] HTML和CSS基础知识

    最近将博客简单地修饰了下,需要用到HTML和CSS代码,花了一天时间学习了一下这两方面的知识.虽然内容很简单,但是足够用来修改自己的博客了. 1. HTML 1.1. HTML介绍 HTML与CSS的 ...

  7. SpringMVC+Spring+MyBatis配置

    今天配置项目时遇到一个问题,tomcat启动没有报错,但是访问页面的时总是报404,后台打印的日志是: 8080-exec-1] WARN springframework.web.servlet.Pa ...

  8. Ubuntu下codeblocks编译器程序执行对话框内能进行粘贴编辑操作的指令

    如这个:  gnome-terminal  -t $TITLE -x

  9. BZOJ1086 王室联邦 —— 树分块

    题目链接:https://vjudge.net/problem/HYSBZ-1086 1086: [SCOI2005]王室联邦 Time Limit: 10 Sec  Memory Limit: 16 ...

  10. mac配置apache

    http://www.cnblogs.com/snandy/archive/2012/11/13/2765381.html 用自带的 sudo apachectl -v sudo apachectl ...