如何知道我應該使用哪個版本的pom依賴項,如果它的版本不在jar名稱中。例如jar commons-lang.jar,我應該使用哪個版本的pom依賴項?我應該使用哪個pom依賴項用於jar commons-lang.jar
下面是行家中央回購其搜索結果 - http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22net.sf.staccatocommons%22%20AND%20a%3A%22commons-lang%22
如何知道我應該使用哪個版本的pom依賴項,如果它的版本不在jar名稱中。例如jar commons-lang.jar,我應該使用哪個版本的pom依賴項?我應該使用哪個pom依賴項用於jar commons-lang.jar
下面是行家中央回購其搜索結果 - http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22net.sf.staccatocommons%22%20AND%20a%3A%22commons-lang%22
如果你正在遷移到Maven,只是有一堆瓶子,然後你可以試着在這些罐子裏面檢查它們的META-INF/MANIFEST.MF
文件。
我剛打開commons-lang.jar
,看到在其META-INF/MANIFEST.MF
如下:
...
Implementation-Title: Commons Lang
Implementation-Vendor: The Apache Software Foundation
Implementation-Vendor-Id: org.apache
Implementation-Version: 2.4
...
所以,你可以在pom.xml
使用Implementation-Version
爲您的版本:
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
</dependency>
很多罐子沒有清單文件中的信息。那就是當我在我的回答中使用sha1校驗和技巧時... – 2012-02-07 17:24:00
首先,使用Apache的一個。
其次,你有兩個選項,2.x或3.x分支;從搜索mvnrepository.com:
2.6
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
3.1
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
如果你使用Maven的時候,你不應該有 「只是一個罐子」,你應該只知道關於POM依賴關係。
(截至2014年2月就看3.3.2,2.x系列仍處於2.6。請注意,您可能都在同一個應用程序,因爲他們不同封裝的使用。)
而其他的答案是正確的一個非常方便的方法來找到一個未知的jar的完全匹配,你擁有的只是jar本身,並且它不包含有用的清單是創建jar的sha1校驗和,然後在上執行校驗和搜索位於高級搜索的底部或您自己的下載中央存儲庫索引的Nexus存儲庫服務器實例上。
順便說一句,你在中央搜索是不正確的,因爲它有錯誤的groupId作爲它的一部分。這裏是一個糾正鏈接:
http://search.maven.org/#search%7Cga%7C1%7C%22commons-lang%22
你確定你使用正確的組ID?我寧願使用Apache中的一個(http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22commons-lang%22%20AND%20a%3A%22commons-lang%22) – 2012-02-07 16:08:10
但是我應該使用哪個版本?我只有一個名爲commons-lang.jar的jar。我應該使用哪個版本? – 2012-02-07 16:13:44
您是否嘗試打開JAR並查看META-INF目錄?有時版本是在那裏給出的...如果沒有,你將不得不使用MD5對Apache目錄(http://archive.apache.org/dist/commons/lang/binaries/) – 2012-02-07 16:16:50