最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

詳解使用Maven構(gòu)建多模塊項(xiàng)目(圖文)

 更新時間:2017年09月26日 09:44:23   作者:H__D  
這篇文章主要介紹了詳解使用Maven構(gòu)建多模塊項(xiàng)目(圖文),非常具有實(shí)用價值,需要的朋友可以參考下

Maven多模塊項(xiàng)目,適用于一些比較大的項(xiàng)目,通過合理的模塊拆分,實(shí)現(xiàn)代碼的復(fù)用,便于維護(hù)和管理。尤其是一些開源框架,也是采用多模塊的方式,提供插件集成,用戶可以根據(jù)需要配置指定的模塊。

項(xiàng)目結(jié)構(gòu)如下:

     test-hd-parent   (父級)
       ---pom.xml
       ---test-hd-api     (第三方接口層)
          ----pom.xml 
       ---test-hd-foundation  (基礎(chǔ)工具層)
          ----pom.xml
       ---test-hd-resource  (資源層) 
          ----pom.xml
       ---test-hd-service    (邏輯業(yè)務(wù)層)
          ----pom.xml
       ---test-hd-modules    (web層)
          ----pom.xml
            ---test-hd-www      (web模塊1)
              ----pom.xml
            ---test-hd-admin      (web模塊2)
              ----pom.xml  

創(chuàng)建一個父maven工程

新建一個maven項(xiàng)目,選擇存儲位置,并選擇創(chuàng)建一個簡單的maven工程

輸入Group Id、Artifact Id、Packaging,packaging選擇pom包

    

生成父工程,pom.xml如下

   

刪除工程中的src 目錄

    

創(chuàng)建子模塊

右擊父工程名---》New---》Project,然后選擇新建一個maven module工程

    

設(shè)置子工程名以及父工程,再設(shè)置快速創(chuàng)建模式

    

得到子工程(test-hd-api,第三方接口層),設(shè)置編譯的jdk

    

同理設(shè)置,子模塊:test-hd-foundation(基礎(chǔ)工具層)、test-hd-resource(資源層) 、test-hd-service(邏輯業(yè)務(wù)層)
新建test-hd-modules (web層),選擇創(chuàng)建一個a simple project,輸入Group Id、Artifact Id、Packaging,packaging選擇pom包

        

創(chuàng)建web子模塊

web子模塊在建在test-hd-modules (web層)里面,右擊test-hd-modules 工程名---》New---》Project,然后選擇新建一個maven module工程,設(shè)置子工程名以及父工程,選擇新建web項(xiàng)目

    

配置maven web項(xiàng)目,參照:【Maven】Eclipse 使用Maven創(chuàng)建Java Web項(xiàng)目

同理可以配置其他的web子模塊   test-hd-admin(web模塊2)

    

配置個模塊的依賴

在parent項(xiàng)目pom.xml中建立依賴管理(dependencyManagement)

<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.hd</groupId>
 <artifactId>test-hd-parent</artifactId>
 <version>0.0.1-SNAPSHOT</version>
 <packaging>pom</packaging>
 <modules>
  <module>test-hd-api</module>
  <module>test-hd-service</module>
  <module>test-hd-resource</module>
  <module>test-hd-foundation</module>
  <module>test-hd-modules</module>
 </modules>


 <!-- maven依賴 -->
 <dependencyManagement>

  <dependencies>
   <!-- hd -->
   <dependency>
    <groupId>com.hd</groupId>
    <artifactId>test-hd-api</artifactId>
    <version>0.0.1-SNAPSHOT</version>
   </dependency>

   <dependency>
    <groupId>com.hd</groupId>
    <artifactId>test-hd-service</artifactId>
    <version>0.0.1-SNAPSHOT</version>
   </dependency>

   <dependency>
    <groupId>com.hd</groupId>
    <artifactId>test-hd-resource</artifactId>
    <version>0.0.1-SNAPSHOT</version>
   </dependency>

   <dependency>
    <groupId>com.hd</groupId>
    <artifactId>test-hd-foundation</artifactId>
    <version>0.0.1-SNAPSHOT</version>
   </dependency>

   <!-- Servlet -->
   <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.0.1</version>
    <scope>provided</scope>
   </dependency>
   <dependency>
    <groupId>javax.servlet.jsp</groupId>
    <artifactId>jsp-api</artifactId>
    <version>2.2</version>
    <scope>provided</scope>
   </dependency>

   <!-- jstl -->
   <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
   </dependency>

   <dependency>
    <groupId>taglibs</groupId>
    <artifactId>standard</artifactId>
    <version>1.1.2</version>
   </dependency>

   <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
   </dependency>

  </dependencies>
 </dependencyManagement>

</project>

test-hd-foundation中的依賴

<?xml version="1.0"?>
<project
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <modelVersion>4.0.0</modelVersion>
 <parent>
  <groupId>com.hd</groupId>
  <artifactId>test-hd-parent</artifactId>
  <version>0.0.1-SNAPSHOT</version>
 </parent>
 <artifactId>test-hd-foundation</artifactId>

 <dependencies>

  <!-- servlet -->
  <dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>jstl</artifactId>
  </dependency>

  <dependency>
   <groupId>taglibs</groupId>
   <artifactId>standard</artifactId>
  </dependency>

  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
  </dependency>
 </dependencies>

 <build>
  <plugins>
   <!-- define the project compile level -->
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
     <source>1.7</source>
     <target>1.7</target>
    </configuration>
   </plugin>
  </plugins>
 </build>
</project>

test-hd-api中的依賴關(guān)系

<?xml version="1.0"?>
<project
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <modelVersion>4.0.0</modelVersion>
 <parent>
  <groupId>com.hd</groupId>
  <artifactId>test-hd-parent</artifactId>
  <version>0.0.1-SNAPSHOT</version>
 </parent>
 <artifactId>test-hd-api</artifactId>
 <dependencies>

  <dependency>
   <groupId>com.hd</groupId>
   <artifactId>test-hd-foundation</artifactId>
  </dependency>

  <!-- servlet -->
  <dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>jstl</artifactId>
  </dependency>

  <dependency>
   <groupId>taglibs</groupId>
   <artifactId>standard</artifactId>
  </dependency>

  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
  </dependency>
 </dependencies>
 <build>
  <plugins>
   <!-- define the project compile level -->
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
     <source>1.7</source>
     <target>1.7</target>
    </configuration>
   </plugin>
  </plugins>
  <finalName>test-hd-api</finalName>
 </build>
</project>

test-hd-resource中的依賴關(guān)系

<?xml version="1.0"?>
<project
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <modelVersion>4.0.0</modelVersion>
 <parent>
  <groupId>com.hd</groupId>
  <artifactId>test-hd-parent</artifactId>
  <version>0.0.1-SNAPSHOT</version>
 </parent>
 <artifactId>test-hd-resource</artifactId>
 <dependencies>

  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
  </dependency>
 </dependencies>

 <build>
  <plugins>
   <!-- define the project compile level -->
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
     <source>1.7</source>
     <target>1.7</target>
    </configuration>
   </plugin>
  </plugins>
 </build>
</project>

test-hd-service中的依賴關(guān)系

<?xml version="1.0"?>
<project
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <modelVersion>4.0.0</modelVersion>
 <parent>
  <groupId>com.hd</groupId>
  <artifactId>test-hd-parent</artifactId>
  <version>0.0.1-SNAPSHOT</version>
 </parent>
 <artifactId>test-hd-service</artifactId>
 <dependencies>

  <dependency>
   <groupId>com.hd</groupId>
   <artifactId>test-hd-foundation</artifactId>
  </dependency>

  <dependency>
   <groupId>com.hd</groupId>
   <artifactId>test-hd-api</artifactId>
  </dependency>

  <!-- servlet -->
  <dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>jstl</artifactId>
  </dependency>

  <dependency>
   <groupId>taglibs</groupId>
   <artifactId>standard</artifactId>
  </dependency>

  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
  </dependency>
 </dependencies>


 <build>
  <plugins>
   <!-- define the project compile level -->
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
     <source>1.7</source>
     <target>1.7</target>
    </configuration>
   </plugin>
  </plugins>
  <finalName>test-hd-service</finalName>
 </build>
</project>

test-hd-module中的依賴關(guān)系 

<?xml version="1.0" encoding="UTF-8"?>
<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.hd</groupId>
  <artifactId>test-hd-parent</artifactId>
  <version>0.0.1-SNAPSHOT</version>
 </parent>

 <artifactId>test-hd-modules</artifactId>
 <packaging>pom</packaging>

 <modules>
  <module>test-hd-www</module>
  <module>test-hd-admin</module>
 </modules>

 <dependencies>

  <dependency>
   <groupId>com.hd</groupId>
   <artifactId>test-hd-foundation</artifactId>
  </dependency>

  <dependency>
   <groupId>com.hd</groupId>
   <artifactId>test-hd-service</artifactId>
  </dependency>
  <dependency>
   <groupId>com.hd</groupId>
   <artifactId>test-hd-api</artifactId>
  </dependency>

  <dependency>
   <groupId>com.hd</groupId>
   <artifactId>test-hd-resource</artifactId>
  </dependency>

  <!-- servlet -->
  <dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>jstl</artifactId>
  </dependency>

  <dependency>
   <groupId>taglibs</groupId>
   <artifactId>standard</artifactId>
  </dependency>

  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
  </dependency>

 </dependencies>
</project>

 test-hd-www中的依賴關(guān)系 

 <?xml version="1.0"?>
<project
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <modelVersion>4.0.0</modelVersion>
 <parent>
  <groupId>com.hd</groupId>
  <artifactId>test-hd-modules</artifactId>
  <version>0.0.1-SNAPSHOT</version>
 </parent>
 <artifactId>test-hd-www</artifactId>
 <packaging>war</packaging>

 <build>
  <plugins>
   <!-- define the project compile level -->
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
     <source>1.7</source>
     <target>1.7</target>
    </configuration>
   </plugin>
  </plugins>
  <finalName>test-hd-www</finalName>
 </build>

</project>

最后使用maven-update整個工程,右擊父工程名--》Maven--》Update Project

    

打包和發(fā)布

打包,右擊父工程名 test-hd-parent---->Run As--->Maven Install

 

打包web子工程,右擊工程名test-hd-www--->Run As ---> Maven Build...---> Goals: clean package--->Run

  

            

右擊工程名test-hd-www,進(jìn)行刷新,找到war包,放到tomcat的webapps中,啟動tomcat,即可訪問工程http://localhost:8080/test-hd-www

    

可以去tomcat下面webapps》test-hd-www》WEB-INF》lib中,看到引用的jar包

    

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。 

相關(guān)文章

  • SpringBoot過濾器實(shí)現(xiàn)項(xiàng)目內(nèi)接口過濾詳解

    SpringBoot過濾器實(shí)現(xiàn)項(xiàng)目內(nèi)接口過濾詳解

    這篇文章主要為大家詳細(xì)介紹了SpringBoot如何利用過濾器實(shí)現(xiàn)項(xiàng)目內(nèi)接口過濾,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起了解一下
    2023-04-04
  • Java實(shí)現(xiàn)提取圖片邊緣的示例代碼

    Java實(shí)現(xiàn)提取圖片邊緣的示例代碼

    這篇文章主要為大家詳細(xì)介紹了如何利用Java實(shí)現(xiàn)提取圖片邊緣的功能,文中的示例代碼講解詳細(xì),具有一定的學(xué)習(xí)價值,感興趣的小伙伴可以了解一下
    2023-06-06
  • SpringBoot使用Redis進(jìn)行限流功能實(shí)現(xiàn)

    SpringBoot使用Redis進(jìn)行限流功能實(shí)現(xiàn)

    Spring Boot中使用Redis實(shí)現(xiàn)限流功能是一種常見的做法,特別是在高并發(fā)場景下,限流可以有效防止系統(tǒng)過載,保證服務(wù)的穩(wěn)定性,本文就來詳細(xì)的介紹一下SpringBoot使用Redis進(jìn)行限流功能實(shí)現(xiàn),感興趣的可以了解一下
    2025-10-10
  • 詳解Java的Struts框架中上傳文件和客戶端驗(yàn)證的實(shí)現(xiàn)

    詳解Java的Struts框架中上傳文件和客戶端驗(yàn)證的實(shí)現(xiàn)

    這篇文章主要介紹了Java的Struts框架中上傳文件和客戶端驗(yàn)證的實(shí)現(xiàn),Struts是Java的SSH三大web開發(fā)框架之一,需要的朋友可以參考下
    2015-12-12
  • Java原子類中的AtomicInteger類詳解

    Java原子類中的AtomicInteger類詳解

    這篇文章主要介紹了Java原子類中的AtomicInteger類詳解,原子類可以保證對"變量"操作的,原子性、有序性、可見性,我們可以通過AtomicInteger類,來看看它們是怎樣工作的,需要的朋友可以參考下
    2023-10-10
  • Spring?Cloud?Sentinel快速入門步驟

    Spring?Cloud?Sentinel快速入門步驟

    本文介紹了Sentinel,一個用于企業(yè)級微服務(wù)開發(fā)的流量控制、熔斷降級和系統(tǒng)負(fù)載保護(hù)的組件,Sentinel的核心概念包括資源、規(guī)則和SlotChain,其三大核心功能分別是流量控制、熔斷降級和系統(tǒng)保護(hù),感興趣的朋友跟隨小編一起看看吧
    2025-11-11
  • Springboot?配置線程池創(chuàng)建線程及配置?@Async?異步操作線程池詳解

    Springboot?配置線程池創(chuàng)建線程及配置?@Async?異步操作線程池詳解

    這篇文章主要介紹了Springboot?配置線程池創(chuàng)建線程及配置?@Async?異步操作線程池詳解,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價值,需要的小伙伴可以參考一下
    2022-09-09
  • JFormDesigner(IDEA)下載方法

    JFormDesigner(IDEA)下載方法

    JFormDesigner是一種Java Swing GUI設(shè)計(jì)工具,可快速創(chuàng)建用戶界面,支持多種布局管理器,如GridBagLayout、SpringLayout等,本文給大家介紹JFormDesigner(IDEA)下載方法,感興趣的朋友跟隨小編一起看看吧
    2023-12-12
  • Lombok不生效,提示java:?找不到符號的解決方案

    Lombok不生效,提示java:?找不到符號的解決方案

    這篇文章主要介紹了Lombok不生效,提示java:?找不到符號的解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-07-07
  • Java 8實(shí)現(xiàn)任意參數(shù)的單鏈表

    Java 8實(shí)現(xiàn)任意參數(shù)的單鏈表

    這篇文章主要為大家詳細(xì)介紹了Java 8實(shí)現(xiàn)任意參數(shù)的單鏈表,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-10-10

最新評論

托里县| 衡水市| 纳雍县| 晋江市| 托里县| 柳林县| 东乡族自治县| 余江县| 白水县| 喀什市| 建平县| 永修县| 韶山市| 基隆市| 额济纳旗| 湖口县| 深圳市| 金沙县| 潢川县| 龙口市| 朝阳县| 五大连池市| 栖霞市| 杭锦后旗| 行唐县| 新河县| 盈江县| 顺昌县| 临汾市| 梓潼县| 弥渡县| 秭归县| 土默特左旗| 潼南县| 漾濞| 萍乡市| 色达县| 靖安县| 昂仁县| 景宁| 陇西县|