Failure to find net.sf.json-lib:json-lib:jar:2.4 in http://uk.maven.org/maven2/ was cached in...

Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Failure to find net.sf.json-lib:json-lib:jar:1.5:2.4 in http://uk.maven.org/maven2/ was cached in the local repository, resolution will not be reattempted until the update interval of ui has elapsed or updates are forced

在项目中添加json-lib依赖时:

<dependency>
    <groupId>net.sf.json-libgroupId>
    <artifactId>json-libartifactId>
    <version>2.4version>
dependency>

项目编译时,执行 mvn compile -X 查看到具体的详细信息:提示: Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Failure to find net.sf.json-lib:json-lib:jar:1.5:2.4 in http://uk.maven.org/maven2/ was cached in the local repository, resolution will not be reattempted until the update interval of ui has elapsed or updates are forced
的错误,

Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project com.example:myboot:jar:0.0.1-SNAPSHOT: Failure to find net.sf.json-lib:json-lib:jar:1.5:2.4 in http://uk.maven.org/maven2/ was cached in the local repository, resolution will not be reattempted until the update interval of ui has elapsed or updates are forced
	at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:211)
	at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:195)
	... 24 more
Caused by: org.eclipse.aether.resolution.DependencyResolutionException: Failure to find net.sf.json-lib:json-lib:jar:1.5:2.4 in http://uk.maven.org/maven2/ was cached in the local repository, resolution will not be reattempted until the update interval of ui has elapsed or updates are forced
	at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:384)
	at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:205)
	... 25 more

根据提示打开: http://uk.maven.org/maven2/net/sf/json-lib/json-lib/2.4/

看到:

Failure to find net.sf.json-lib:json-lib:jar:2.4 in http://uk.maven.org/maven2/ was cached in..._第1张图片

jar的名称中多了 jdk13、jdk15,所以需要添加classfier。classifier表示在相同版本下针对不同的环境或者jdk使用的jar, 如果配置了这个元素,则会将这个元素名在加在jar包的后面来查找相应的jar,所以上面的json-lib-2,4是找不到jar包的。修改为以下配置:

<dependency>
            <groupId>net.sf.json-libgroupId>
            <artifactId>json-libartifactId>
            <version>2.4version>
            <classifier>JDK15classifier>
        dependency>

这样配置即可找到json-lib-2.4-jdk15.jar 。

你可能感兴趣的:(【Maven】)