Maven: 缺少 net.sf.json-lib

我找到了 net.sf.json-lib 在中央储存库。复制粘贴了依赖项(版本2.3) ,然后在构建时得到了这个错误:

[INFO] Unable to find resource 'net.sf.json-lib:json-lib:jar:2.2.3' in repository central (http://repo1.maven.org/maven2)


[ERROR] BUILD ERROR
[INFO] ---------------------------------------------------------
[INFO] Failed to resolve artifact.


Missing:
----------
1) net.sf.json-lib:json-lib:jar:2.3


Try downloading the file manually from the project website.

我尝试使用版本2.2.3,但是我得到了同样的错误。为什么我会得到这个错误?我可以通过本地安装来覆盖它,但我想知道问题出在哪里。

Edit -我从本地存储库中删除了该包,然后再次尝试,这次得到了校验和错误。我想我应该向 json-lib 提交一份错误报告。

[WARNING] *** CHECKSUM FAILED - Error retrieving checksum file for net/sf/json-lib/json-lib/2.3/json
-lib-2.3.pom - IGNORING
76679 次浏览

Barring khimarbaise's comment about trustworthiness, you can install it locally using maven install:

mvn install:install-file  -Dfile=path-to-your-artifact-jar
-DgroupId=your.groupId
-DartifactId=your-artifactId
-Dversion=version
-Dpackaging=jar
-DlocalRepositoryPath=path-to-specific-local-repo

Looking at the maven-central repo, you need to specify a classifier for this dependency.

Either jdk13 or jdk15, like this:

<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>

For gradle as sample

compile 'net.sf.json-lib:json-lib:2.4:jdk15'

OR

compile group: 'net.sf.json-lib', name: 'json-lib', version: '2.4', classifier: 'jdk15'

I searched for more classifier's could not find anything other than jdk15 (don't go looking or jdk16 or jdk17)

For ivy users, after trying many different iterations to configure my ivy.xml to properly find this dependency, this finally worked for me:

  <dependency org="net.sf.json-lib" name="json-lib" rev="2.4">
<artifact name="json-lib" url="http://repo1.maven.org/maven2/net/sf/json-lib/json-lib/2.4/json-lib-2.4-jdk15.jar"/>
</dependency>