Idea創(chuàng)建多模塊maven聚合項(xiàng)目的實(shí)現(xiàn)
1.怎么理解maven的繼承和聚合
maven多模塊項(xiàng)目通常由一個父模塊和若干個子模塊構(gòu)成,每個模塊都對應(yīng)著一個pom.xml。它們之間通過繼承和聚合(也稱作多模塊)相互關(guān)聯(lián)。多模塊適用于一些比較大的項(xiàng)目,通過合理的模塊拆分,實(shí)現(xiàn)代碼的復(fù)用,便于維護(hù)和管理。
繼承:和java中的繼承有點(diǎn)類似,就是父pom.xml聲明的版本和引用的jar,子模塊可以不用再引用直接調(diào)用。
聚合:父模塊包含多個子模塊就是聚合,多個子模塊之間可以調(diào)用,但是要注意關(guān)系,不要兩個互相依賴,這樣做的好處就是可以通過一條命令進(jìn)行構(gòu)建
注意:
groupId是項(xiàng)目組織唯一的標(biāo)識符,實(shí)際對應(yīng)JAVA的包的結(jié)構(gòu),artifactId是項(xiàng)目的唯一的標(biāo)識符,實(shí)際對應(yīng)項(xiàng)目的名稱,就是項(xiàng)目根目錄的名稱。groupId一般分為多個段,一般第一段為域,第二段為公司名稱,第三段通常為項(xiàng)目名稱。
2.Idea創(chuàng)建多模塊項(xiàng)目
2.1創(chuàng)建父模塊(空的maven項(xiàng)目)




pom.xml配置 <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.6.RELEASE</version> </parent> <groupId>cn.yskcoder.fire</groupId> <artifactId>fire</artifactId> <packaging>pom</packaging> <version>v1.0</version> <modules> <module>fire-common</module> <module>fire-dao</module> <module>fire-service</module> <module>fire-web</module> </modules> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> <spring-boot.version>2.1.6.RELEASE</spring-boot.version> </properties>
2.2.創(chuàng)建工具類(common)模塊(dao、service同這個操作一樣)



pom.xml配置 <modelVersion>4.0.0</modelVersion> <parent> <artifactId>fire</artifactId> <groupId>cn.yskcoder.fire</groupId> <version>v1.0</version> </parent> <!--模塊信息--> <packaging>jar</packaging> <name>fire-common</name> <artifactId>fire-common</artifactId> <description>fire 通用工具類模塊</description> <!--模塊依賴--> <dependencies> </dependencies>
2.3.創(chuàng)建數(shù)據(jù)庫訪問(dao)模塊(只貼pom.xml代碼)
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>fire</artifactId>
<groupId>cn.yskcoder.fire</groupId>
<version>v1.0</version>
</parent>
<!--模塊信息-->
<packaging>war</packaging>
<name>fire-web</name>
<artifactId>fire-web</artifactId>
<description>fire web模塊</description>
<!--模塊依賴-->
<dependencies>
<dependency> <groupId>cn.yskcoder.fire</groupId>
<artifactId>fire-service</artifactId>
<version>v1.0</version>
</dependency>
<dependency> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/webapp</directory>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
3.Idea打包多模塊項(xiàng)目
clean package -Dmaven.test.skip=true
接下來有空會繼續(xù)更新這個項(xiàng)目
https://github.com/yskcoder/Fire
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- IntelliJ IDEA創(chuàng)建maven多模塊項(xiàng)目(圖文教程)
- 基于maven使用IDEA創(chuàng)建多模塊項(xiàng)目
- IntelliJ IDEA 構(gòu)建maven多模塊工程項(xiàng)目(詳細(xì)多圖)
- springboot+idea+maven 多模塊項(xiàng)目搭建的詳細(xì)過程(連接數(shù)據(jù)庫進(jìn)行測試)
- Intellij Idea 多模塊Maven工程中模塊之間無法相互引用問題
- 利用IDEA工具修改Maven多模塊項(xiàng)目標(biāo)識包名全過程記錄
- 手把手教你使用IDEA創(chuàng)建多模塊(maven)項(xiàng)目
- Maven和IntelliJ IDEA搭建多模塊微服務(wù)的實(shí)現(xiàn)
相關(guān)文章
DUCC配置平臺實(shí)現(xiàn)一個動態(tài)化線程池示例代碼
這篇文章主要為大家介紹了DUCC配置平臺實(shí)現(xiàn)一個動態(tài)化線程池示例代碼,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-02-02
基于SpringBoot2的Shiro最簡配置操作(兩個文件)
這篇文章主要介紹了基于SpringBoot2的Shiro最簡配置操作(兩個文件),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-01-01
SpringCloud項(xiàng)目中Feign組件添加請求頭所遇到的坑及解決
這篇文章主要介紹了SpringCloud項(xiàng)目中Feign組件添加請求頭所遇到的坑及解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-04-04
javaSE,javaEE,javaME的區(qū)別小結(jié)
本篇文章小編就為大家簡單說說JavaSE、JavaEE、JavaME三者之間的區(qū)別,需要的朋友可以過來參考下,感興趣的小伙伴們可以參考一下2023-08-08
解決java字符串轉(zhuǎn)換成時間Unparseable date出錯的問題
這篇文章主要介紹了解決java字符串轉(zhuǎn)換成時間Unparseable date出錯的問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2021-06-06
intelliJ idea 2023 配置Tomcat 8圖文教程
這篇文章主要介紹了intelliJ idea 2023 配置Tomcat 8教程,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-06-06

