在寫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>