原创

Maven引入json-lib报错Failure to find net.sf.json-libjson-libjar2.4

json-lib是一个java类库,提供将Java对象,包括beans, maps, collections, java arrays and XML等转换成JSON,或者反向转换的功能。json-lib其地址: http://json-lib.sourceforge.net/,执行环境需要以下类库支持:

•  jakarta commons-lang 2.5
•  jakarta commons-beanutils 1.8.0
•  jakarta commons-collections 3.2.1
•  jakarta commons-logging 1.1.1
•  ezmorph 1.0.6

在maven项目pom.xml文件中增加如下内容:

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

但是在执行install命令时找不到相应的jar包,具体错误信息如下:

[ERROR] Failed to execute goal on project cas-client-webapp: Could not resolve dependencies for project org.jasig.cas:cas-client-webapp:war:3.2.1: 
Failure to find net.sf.json-lib:json-lib:jar:2.4 in https://repo.maven.apache.org/maven2 was cached in the local repository, 
resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

这是因为json-lib提供了两个jdk版本的实现, json-lib-2.*-jdk13.jar和json-lib-2.*-jdk15.jar,需要增加classifier配置来解决问题,具体pom.xml文件增加如下信息即可:

<dependency>  
    <groupId>net.sf.json-lib</groupId>  
    <artifactId>json-lib</artifactId>  
    <version>2.4</version>  
    <classifier>jdk15</classifier>  
</dependency>
~阅读全文-人机检测~

微信公众号“Java精选”(w_z90110),专注Java技术干货分享!让你从此路人变大神!回复关键词领取资料:如Mysql、Hadoop、Dubbo、Spring Boot等,免费领取视频教程、资料文档和项目源码。微信搜索小程序“Java精选面试题”,内涵3000+道Java面试题!

涵盖:互联网那些事、算法与数据结构、SpringMVC、Spring boot、Spring Cloud、ElasticSearch、Linux、Mysql、Oracle等

评论

分享:

支付宝

微信