Which pom dependency should I use for jar commons-lang.jar

折月煮酒 提交于 2019-12-01 20:17:26

If you are migrating to Maven and just have a bunch of jars then you can try examining their META-INF/MANIFEST.MF files inside of those jars.

I've just opened commons-lang.jar and saw the following in its META-INF/MANIFEST.MF:

...
Implementation-Title: Commons Lang
Implementation-Vendor: The Apache Software Foundation
Implementation-Vendor-Id: org.apache
Implementation-Version: 2.4
...

So you can use Implementation-Version as your version in pom.xml:

<dependency>
  <groupId>commons-lang</groupId>
  <artifactId>commons-lang</artifactId>
  <version>2.4</version>
</dependency>

First, use the one from Apache.

Second, you have two options, the 2.x or 3.x branches; from searching 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>

If you're using Maven, you shouldn't have "just a jar", you should only know about POM dependencies.

(As of Feb 2014 it's up to 3.3.2, the 2.x series is still at 2.6. Note that you may use both in the same application because of their different packages.)

While the other answers are correct a very handy way to find out exact match for an unknown jar where all you have is the jar itself and it does not contain a useful manifest is to create a sha1 checksum of the jar and then do a checksum search on http://search.maven.org in the Advanced Search at the bottom or on your own instance of a Nexus repository server that downloaded the index of the Central Repository.

And btw your search on central was incorrect since it had the wrong groupId as part of it. Here is a corrected link:

http://search.maven.org/#search%7Cga%7C1%7C%22commons-lang%22

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!