maven的pom.xml用 解決版本問題


用maven管理庫依賴,有個好處就是連同庫的依賴的全部jar文件一起下載,免去手工添加的麻煩,但同時也帶來了同一個jar會被下載了不同版本的問題,好在pom的配置里面允許用<exclusion>來排除一些不需要同時下載的依賴jar 。

      比如配置struts-core,它會同時下載javassist和asm相關的jar,但版本又不夠新,這時可以排除它們:

 

[html]  view plain  copy
 
  1. <!-- Struts2 -->  
  2.         <dependency>  
  3.             <groupId>org.apache.struts</groupId>  
  4.             <artifactId>struts2-core</artifactId>  
  5.             <version>${struts.version}</version>  
  6.             <exclusions>  
  7.                 <exclusion>  
  8.                     <groupId>javassist</groupId>  
  9.                     <artifactId>javassist</artifactId>  
  10.                 </exclusion>  
  11.                 <exclusion<!-- we prefer our explicit version, though it should be the same -->  
  12.                     <groupId>asm</groupId>  
  13.                     <artifactId>asm</artifactId>  
  14.                 </exclusion>  
  15.                 <exclusion<!-- we prefer our explicit version, though it should be the same -->  
  16.                     <groupId>asm</groupId>  
  17.                     <artifactId>asm-commons</artifactId>  
  18.                 </exclusion>  
  19.                 <exclusion<!-- we prefer our explicit version, though it should be the same -->  
  20.                     <groupId>org.ow2.asm</groupId>  
  21.                     <artifactId>asm</artifactId>  
  22.                 </exclusion>  
  23.                 <exclusion<!-- we prefer our explicit version, though it should be the same -->  
  24.                     <groupId>org.ow2.asm</groupId>  
  25.                     <artifactId>asm-commons</artifactId>  
  26.                 </exclusion>  
  27.             </exclusions>  
  28.         </dependency>  


 

版權聲明:本文為博主原創文章,未經博主允許不得轉載。 https://blog.csdn.net/rocklee/article/details/51692054


免責聲明!

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



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