Maven exclusions(排除依賴)


 

在寫pom的時候,我們寫的一個依賴往往會依賴於其他的包,而這些包可能是過時的不安全的,因此需要排除並重新引用安全的版本,先在依賴這個項目的pom中去除想排除的依賴,再添加指定版本的依賴。

pom的依賴關系可以在idea查看,打開pom.xml。右鍵點擊Diagram,即可顯示完整的依賴關系圖,包括pom沒有明文寫出的依賴。可以根據它來判斷依賴是否有被重復引用,同時還能查看依賴的版本,十分方便

<dependency>  
            <groupId>org.apache.struts</groupId>  
            <artifactId>struts2-core</artifactId>  
            <version>${struts.version}</version>  
            <exclusions>  
                <exclusion> <!-- we prefer our explicit version, though it should be the same -->  
                    <groupId>asm</groupId>  
                    <artifactId>asm</artifactId>  
                </exclusion>  
            </exclusions>  
        </dependency>  
<!-- https://mvnrepository.com/artifact/asm/asm -->
<dependency>
    <groupId>asm</groupId>
    <artifactId>asm</artifactId>
    <version>3.3.1</version>
</dependency>

 


免責聲明!

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



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