天天看點

依賴類型dependency type在maven中的作用

看看下面這段pom配置

<code>...</code>

<code>&lt;</code><code>dependency</code><code>&gt;</code>

<code>    </code><code>&lt;</code><code>groupId</code><code>&gt;xxx&lt;/</code><code>groupId</code><code>&gt;</code>

<code>    </code><code>&lt;</code><code>artifactId</code><code>&gt;yyy&lt;/</code><code>artifactId</code><code>&gt;</code>

<code>    </code><code>&lt;</code><code>type</code><code>&gt;ejb&lt;/</code><code>type</code><code>&gt;</code>

<code>&lt;/</code><code>dependency</code><code>&gt;</code>

這個&lt;type&gt;很多maven相關的資料中都未曾提及,而上網搜了一下中文資源,這些文章都把compile、runtime、test等本屬于scope的概念混淆為“依賴類型”&lt;type&gt;的概念。而且,關于這個&lt;type&gt;的解釋也非常少。

我也是看了Maven 3 Cookbook之後從中找到些隻言片語,反推出type的作用。

看書中原文(P134. How it works...):

Adding the type of apk to the dependency allows the Maven Android plugin to find the Android package of the application.

不難看出,&lt;type&gt;apk&lt;/type&gt;告訴maven使用maven android plugin來進行處理&lt;type&gt;為apk的依賴。進而推想&lt;type&gt;ejb&lt;/type&gt;就是告訴maven使用maven ejb plugin來處理。如果想知道ejb plugin如何處理這類dependency,那就去查查ejb plugin的詳細說明吧,這個plugin的說明網上有很多。

本文轉自 rickqin 51CTO部落格,原文連結:http://blog.51cto.com/rickqin/1738774

繼續閱讀