【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

 

 

問題解決!!!!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM