怎么在Idea中創(chuàng)建一個(gè)多模塊maven聚合項(xiàng)目?很多新手對(duì)此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來(lái)學(xué)習(xí)下,希望你能有所收獲。
成都創(chuàng)新互聯(lián)公司專(zhuān)注于企業(yè)成都全網(wǎng)營(yíng)銷(xiāo)推廣、網(wǎng)站重做改版、新密網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、HTML5、購(gòu)物商城網(wǎng)站建設(shè)、集團(tuán)公司官網(wǎng)建設(shè)、外貿(mào)營(yíng)銷(xiāo)網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁(yè)設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性?xún)r(jià)比高,為新密等各大城市提供網(wǎng)站開(kāi)發(fā)制作服務(wù)。
1.怎么理解maven的繼承和聚合
maven多模塊項(xiàng)目通常由一個(gè)父模塊和若干個(gè)子模塊構(gòu)成,每個(gè)模塊都對(duì)應(yīng)著一個(gè)pom.xml。它們之間通過(guò)繼承和聚合(也稱(chēng)作多模塊)相互關(guān)聯(lián)。多模塊適用于一些比較大的項(xiàng)目,通過(guò)合理的模塊拆分,實(shí)現(xiàn)代碼的復(fù)用,便于維護(hù)和管理。
繼承:和java中的繼承有點(diǎn)類(lèi)似,就是父pom.xml聲明的版本和引用的jar,子模塊可以不用再引用直接調(diào)用。
聚合:父模塊包含多個(gè)子模塊就是聚合,多個(gè)子模塊之間可以調(diào)用,但是要注意關(guān)系,不要兩個(gè)互相依賴(lài),這樣做的好處就是可以通過(guò)一條命令進(jìn)行構(gòu)建
注意:
groupId是項(xiàng)目組織唯一的標(biāo)識(shí)符,實(shí)際對(duì)應(yīng)JAVA的包的結(jié)構(gòu),artifactId是項(xiàng)目的唯一的標(biāo)識(shí)符,實(shí)際對(duì)應(yīng)項(xiàng)目的名稱(chēng),就是項(xiàng)目根目錄的名稱(chēng)。groupId一般分為多個(gè)段,一般第一段為域,第二段為公司名稱(chēng),第三段通常為項(xiàng)目名稱(chē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)建工具類(lèi)(common)模塊(dao、service同這個(gè)操作一樣)



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 通用工具類(lèi)模塊</description> <!--模塊依賴(lài)--> <dependencies> </dependencies>
2.3.創(chuàng)建數(shù)據(jù)庫(kù)訪問(wèn)(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>
<!--模塊依賴(lài)-->
<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
看完上述內(nèi)容是否對(duì)您有幫助呢?如果還想對(duì)相關(guān)知識(shí)有進(jìn)一步的了解或閱讀更多相關(guān)文章,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對(duì)創(chuàng)新互聯(lián)的支持。
文章標(biāo)題:怎么在Idea中創(chuàng)建一個(gè)多模塊maven聚合項(xiàng)目
本文鏈接:http://chinadenli.net/article40/pgjeho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)網(wǎng)站制作、網(wǎng)站排名、網(wǎng)站建設(shè)、網(wǎng)站導(dǎo)航、標(biāo)簽優(yōu)化、微信公眾號(hào)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)