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-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
</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
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
看到:
jar的名稱中多了 jdk13、jdk15,所以需要新增classfier。classifier表示在相同版本下針對不同的環境或者jdk使用的jar, 如果配置了這個元素,則會將這個元素名在加在jar包的後面來查詢相應的jar,所以上面的json-lib-2,4是找不到jar包的。修改為以下配置:
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>JDK15</classifier>
</dependency>
這樣配置即可找到json-lib-2.4-jdk15.jar 。