亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

詳解使用Maven構建多模塊項目(圖文)

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

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

項目結構如下:

     test-hd-parent   (父級)
       ---pom.xml
       ---test-hd-api     (第三方接口層)
          ----pom.xml 
       ---test-hd-foundation  (基礎工具層)
          ----pom.xml
       ---test-hd-resource  (資源層) 
          ----pom.xml
       ---test-hd-service    (邏輯業(yè)務層)
          ----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項目,選擇存儲位置,并選擇創(chuàng)建一個簡單的maven工程

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

    

生成父工程,pom.xml如下

   

刪除工程中的src 目錄

    

創(chuàng)建子模塊

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

    

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

    

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

    

同理設置,子模塊:test-hd-foundation(基礎工具層)、test-hd-resource(資源層) 、test-hd-service(邏輯業(yè)務層)
新建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工程,設置子工程名以及父工程,選擇新建web項目

    

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

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

    

配置個模塊的依賴

在parent項目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中的依賴關系

<?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中的依賴關系

<?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中的依賴關系

<?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中的依賴關系 

<?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中的依賴關系 

 <?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,進行刷新,找到war包,放到tomcat的webapps中,啟動tomcat,即可訪問工程http://localhost:8080/test-hd-www

    

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

    

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

相關文章

  • Java中的@Accessors使用詳解

    Java中的@Accessors使用詳解

    這篇文章主要介紹了Java中的@Accessors使用詳解,@RequiredArgsConstructor是Lombok的一個注解,簡化了我們對setter和getter方法操作,它可以作用在類上,也可以作用在類的單個屬性上,需要的朋友可以參考下
    2024-01-01
  • Java中的信號量Semaphore詳細解讀

    Java中的信號量Semaphore詳細解讀

    這篇文章主要介紹了Java中的信號量Semaphore詳細解讀,Java信號量機制可以用來保證線程互斥,創(chuàng)建Semaphore對象傳入一個整形參數(shù),類似于公共資源,需要的朋友可以參考下
    2023-11-11
  • java DOM4J 讀取XML實例代碼

    java DOM4J 讀取XML實例代碼

    最近學習Java,在處理XML文檔的時候,查閱相關資料,發(fā)現(xiàn)了DOM4J這個jre庫,相對C#的XML處理來說,功能還算是跟得
    2013-09-09
  • java實現(xiàn)圖片分割指定大小

    java實現(xiàn)圖片分割指定大小

    這篇文章主要為大家詳細介紹了java實現(xiàn)圖片分割指定大小,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • java 排序算法之冒泡排序

    java 排序算法之冒泡排序

    這篇文章主要介紹了java 排序算法之冒泡排序,文中運用大量的代碼講解相關知識,非常詳細,感興趣的小伙伴可以參考一下
    2021-09-09
  • Java結構型設計模式中建造者模式示例詳解

    Java結構型設計模式中建造者模式示例詳解

    建造者模式,是一種對象構建模式 它可以將復雜對象的建造過程抽象出來,使這個抽象過程的不同實現(xiàn)方法可以構造出不同表現(xiàn)的對象。本文將通過示例講解建造者模式,需要的可以參考一下
    2022-09-09
  • java 使用簡單的demo實例告訴你優(yōu)化算法的強大

    java 使用簡單的demo實例告訴你優(yōu)化算法的強大

    本篇文章介紹了,在java中使用簡單的demo實例告訴你優(yōu)化算法的強大。需要的朋友參考下
    2013-05-05
  • spring cloud feign實現(xiàn)遠程調(diào)用服務傳輸文件的方法

    spring cloud feign實現(xiàn)遠程調(diào)用服務傳輸文件的方法

    這篇文章主要介紹了spring cloud feign實現(xiàn)遠程調(diào)用服務傳輸文件的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-09-09
  • 基于SpringBoot構建電商秒殺項目代碼實例

    基于SpringBoot構建電商秒殺項目代碼實例

    這篇文章主要介紹了基于SpringBoot構建電商秒殺項目代碼實例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2020-05-05
  • 詳解java如何處理各種批量數(shù)據(jù)入庫

    詳解java如何處理各種批量數(shù)據(jù)入庫

    這篇文章主要為大家詳細介紹了java如何使用BlockingQueue處理各種批量數(shù)據(jù)入庫,文中的示例代碼講解詳細,感興趣的小伙伴可以跟隨小編一起學習一下
    2023-11-11

最新評論