mvn pom標(biāo)簽詳解

結(jié)合本人開(kāi)發(fā)經(jīng)驗(yàn),不定期更新。

pom文件默認(rèn)配置:

<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標(biāo)簽

groupId標(biāo)簽表示開(kāi)發(fā)該項(xiàng)目的組織名稱(chēng),一般用組織的倒序網(wǎng)站名稱(chēng)表示

<groupId>com.rayxiao</groupId>

artifactId標(biāo)簽

artifactId表示該項(xiàng)目的名稱(chēng)

packaging標(biāo)簽

packaging標(biāo)簽表示該項(xiàng)目的打包方式,主要有jar(默認(rèn))、war、pom等屬性。
pom屬性表示該項(xiàng)目由多個(gè)子模塊整合打包,每個(gè)module都是一個(gè)maven項(xiàng)目

scope標(biāo)簽

scope標(biāo)簽依賴(lài)范圍,主要有compile(默認(rèn))、test、runtime、provided等屬性。
compile表示參與當(dāng)前項(xiàng)目的編譯,測(cè)試,運(yùn)行周期等,適用于所有階段,會(huì)隨著項(xiàng)目一起發(fā)布;
test表示測(cè)試階段使用;
runtime表示運(yùn)行時(shí)使用;
provided意味著打包的時(shí)候可以不用包進(jìn)去,別的設(shè)施(web容器等)會(huì)提供。理論上可以參與編譯,測(cè)試,運(yùn)行等周期。相當(dāng)于compile,但是在打包階段做了exclude的動(dòng)作。
——————————————————————————————————————
一個(gè)簡(jiǎn)單的pom.xml文件
<pre><code><?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.rayxiao</groupId>
<artifactId>server-rc-test</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>server-rc-test</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project></code></pre>

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容