zoukankan      html  css  js  c++  java
  • Maven多模块构建实例

    创建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] ------------------------------------------------------------------------
    
  • 相关阅读:
    Centos7 定时任务
    Linux启动配置文件和运行等级runlevel
    Linux 网卡命名规则
    将博客搬至CSDN
    Lua调用C++动态链接库.so
    使用shell脚本执行批量mongosh语句
    TCP和UDP详解
    经受时延的确认(Delay ACK)
    18张图带你了解衡量网络性能的四大指标:带宽、时延、抖动、丢包
    TCP学习
  • 原文地址:https://www.cnblogs.com/seve/p/10970655.html
Copyright © 2011-2022 走看看