這篇文章主要介紹Maven項目繼承實現(xiàn)過程的案例分析,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!

多個maven項目之間難免有重復(fù)的pom配置,重復(fù)的配置沒必要重復(fù)寫,maven提供了父子繼承的關(guān)系,重復(fù)的依賴直接放在父項目的pom中。
所以不希望每個開發(fā)者隨意定義maven版本依賴,可以在父項目中進行說明,然后子項目沿用即可。
idea創(chuàng)建父項目(這是一個父項目,也是一個空項目,只需要pom.xml,編寫相關(guān)的依賴, 父項目必須用pom打包的方式):

編輯父項目pom.xml
<?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>
<groupId>com.linewell</groupId>
<artifactId>maven-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<!--父項目必須是pom-->
<packaging>pom</packaging>
<!--定義參數(shù)-->
<properties>
<common.version>2.6</common.version>
<spring.version>4.3.6.RELEASE</spring.version>
</properties>
<!--這邊的依賴子項目會繼承-->
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${common.version}</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>spring-context-support</groupId>
<artifactId>org.springframework</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
當(dāng)前名稱:Maven項目繼承實現(xiàn)過程的案例分析-創(chuàng)新互聯(lián)
路徑分享:http://www.chinadenli.net/article26/dpodjg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App開發(fā)、網(wǎng)站內(nèi)鏈、軟件開發(fā)、商城網(wǎng)站、ChatGPT、網(wǎng)站導(dǎo)航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)