【pom.xml 依赖】使用net.sf.json-lib-2.4-jdk15.jar所需要的其他依赖架包 以及其一直在pom.xml报错的问题

特此声明:

json-lib-2.4-jdk15.jar仅它本身不够,必须如下的几个依赖架包都有才能使用!!!

首先 将.json-lib-2.4-jdk15.jar以及其相关的依赖架包的正确配置给出【pom.xml文件】:

 1 <dependency>
 2             <groupId>net.sf.json-lib</groupId>
 3             <artifactId>json-lib</artifactId>
 4             <version>2.4</version>
 5             <classifier>jdk15</classifier>
 6         </dependency>
 7         <!-- json-lib还需要以下依赖包 -->    
 8         <dependency>
 9             <groupId>commons-lang</groupId>
10             <artifactId>commons-lang</artifactId>
11             <version>2.5</version>
12         </dependency>
13         <dependency>
14             <groupId>commons-beanutils</groupId>
15             <artifactId>commons-beanutils</artifactId>
16             <version>1.9.2</version>
17         </dependency>
18         <dependency>
19             <groupId>commons-collections</groupId>
20             <artifactId>commons-collections</artifactId>
21             <version>3.2.1</version>
22         </dependency>
23         <dependency>
24             <groupId>commons-logging</groupId>
25             <artifactId>commons-logging</artifactId>
26             <version>1.2</version>
27         </dependency>
View Code

其次,说说遇到的问题:

问题1:json-lib:json-lib:jar:2.4一直报错的问题

初始的时候,是这样的:

所报的错误是:Missing artifact net.sf.json-lib:json-lib:jar:2.4

但是此时我的这个架包已经下载我的本地仓库了。这maven是不是搞笑??

解决方法:

但是对比本地仓库中的架包和pom.xml中配置的,总感觉架包有些许不正常,

本地仓库中的架包长这个样子:

查找后发现我们需要在这个JSON架包中添加节点<classifier>jdk15</classifier>:

这个就是网上查到的解决方法:

1 <dependency>
2             <groupId>net.sf.json-lib</groupId>
3             <artifactId>json-lib</artifactId>
4             <version>2.4</version>
5             <classifier>jdk15</classifier>
6         </dependency>
View Code

问题2: json-lib的依赖架包中commons-lang架包一直报错

所报错误如下:

ArtifactTransferException: Failure to transfer commons-lang:commons-lang:jar:2.6 from http://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. Original error: Could not transfer artifact commons-lang:commons-lang:jar:2.6 
 from/to central (http://repo.maven.apache.org/maven2): Connection timed out: connect

说是不能加载这个架包!!

解决问题:

在本地仓库查看之后,发现这个架包在本地也有。这就奇怪了!!

而且不像问题1中的问题一样。这很尴尬!!这一看,明显不是缺少节点!!

然后报出上述问题,可能是:

1.网路不好,下载到本地的架包是损坏的,将其删除,重新下载

2.更换版本较低的架包

于是: 将版本更换为2.5的就好了

1 <dependency>
2             <groupId>commons-lang</groupId>
3             <artifactId>commons-lang</artifactId>
4             <version>2.5</version>
5         </dependency>
View Code

问题解决!!!!

原文地址:https://www.cnblogs.com/sxdcgaq8080/p/5764999.html