詳解 maven的pom.xml用<exclusion>解決版本問題
詳解 maven的pom.xml用<exclusion>解決版本問題
用maven管理庫(kù)依賴,有個(gè)好處就是連同庫(kù)的依賴的全部jar文件一起下載,免去手工添加的麻煩,但同時(shí)也帶來了同一個(gè)jar會(huì)被下載了不同版本的問題,好在pom的配置里面允許用<exclusion>來排除一些不需要同時(shí)下載的依賴jar 。
比如配置struts-core,它會(huì)同時(shí)下載javassist和asm相關(guān)的jar,但版本又不夠新,這時(shí)可以排除它們:
<!-- Struts2 -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts.version}</version>
<exclusions>
<exclusion>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
</exclusion>
<exclusion> <!-- we prefer our explicit version, though it should be the same -->
<groupId>asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
<exclusion> <!-- we prefer our explicit version, though it should be the same -->
<groupId>asm</groupId>
<artifactId>asm-commons</artifactId>
</exclusion>
<exclusion> <!-- we prefer our explicit version, though it should be the same -->
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
<exclusion> <!-- we prefer our explicit version, though it should be the same -->
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
</exclusion>
</exclusions>
</dependency>
如有疑問請(qǐng)留言或者到本站社區(qū)交流討論,希望通過本文能幫助到大家,謝謝大家對(duì)本站的支持!
相關(guān)文章
Java 8 Stream.distinct() 列表去重的操作
這篇文章主要介紹了Java 8 Stream.distinct() 列表去重的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-12-12
HttpsURLConnection上傳文件流(實(shí)例講解)
下面小編就為大家?guī)硪黄狧ttpsURLConnection上傳文件流(實(shí)例講解)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-07-07
IDEA中request.getParameter爆紅問題及解決
這篇文章主要介紹了IDEA中request.getParameter爆紅問題及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-11-11
SpringBoot整合第三方技術(shù)的實(shí)現(xiàn)
本文主要介紹了SpringBoot整合第三方技術(shù)的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-02-02

