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>

猜你喜欢

转载自www.cnblogs.com/34fj/p/11552877.html