maven排查冲突jar包
1. 问题描述
使用maven可以非常方便的管理我们项目的各种依赖,但是也存在着一些问题。当我们在pom.xml文件中引入新的jar包,那么该jar包依赖的其它jar包也会自动被下载。如果这些自动下载的jar包和项目中已存在的jar包版本不一致,那么就会造成jar包版本的冲突。
2. 解决方法
我们可以使用mvn命令来排查项目中存在版本冲突的jar包。
首先,在命令行跳转到当前项目路径(如果使用Idea等工具,可以直接在终端Terminal中运行mvn命令),为了便于查找我们可以把依赖关系写入一个临时文本文件tree.txt。
mvn dependency:tree -Dverbose > tree.txt
然后,打开生成的tree.txt文件,全局搜索”conflict”关键字,即可找到版本冲突的jar包。
[INFO] +- io.springfox
jar:2.6.1:compile
[INFO] | +- io.swagger
jar:1.5.10:compile
[INFO] | +- io.swagger
jar:1.5.10:compile
[INFO] | | +- com.fasterxml.jackson.core
jar:2.8.1:compile (version managed from 2.4.5)
[INFO] | | +- (org.slf4j
jar:1.7.21:compile - version managed from 1.7.10; omitted for duplicate)
[INFO] | | \- (io.swagger
jar:1.5.10:compile - omitted for duplicate)
[INFO] | +- io.springfox
jar:2.6.1:compile
[INFO] | | \- io.springfox
jar:2.6.1:compile
[INFO] | | +- (com.google.guava
jar:18.0:compile - omitted for duplicate)
[INFO] | | +- (com.fasterxml
jar:1.3.1:compile - omitted for duplicate)
[INFO] | | +- (org.slf4j
jar:1.7.21:compile - version managed from 1.6.3; omitted for duplicate)
[INFO] | | +- (org.springframework.plugin
jar:1.2.0.RELEASE:compile - omitted for duplicate)
[INFO] | | \- (org.springframework.plugin
jar:1.2.0.RELEASE:compile - omitted for duplicate)
[INFO] | +- io.springfox
jar:2.6.1:compile
[INFO] | | +- (io.springfox
jar:2.6.1:compile - omitted for duplicate)
[INFO] | | \- (io.springfox
jar:2.6.1:compile - omitted for duplicate)
[INFO] | +- io.springfox
jar:2.6.1:compile
[INFO] | | +- (io.swagger
jar:1.5.10:compile - omitted for duplicate)
[INFO] | | +- (io.swagger
jar:1.5.10:compile - omitted for duplicate)
[INFO] | | +- (io.springfox
jar:2.6.1:compile - omitted for duplicate)
[INFO] | | +- (io.springfox
jar:2.6.1:compile - omitted for duplicate)
[INFO] | | +- (io.springfox
jar:2.6.1:compile - omitted for duplicate)
[INFO] | | +- (com.google.guava
jar:18.0:compile - omitted for duplicate)
[INFO] | | +- (com.fasterxml
jar:1.3.1:compile - omitted for duplicate)
[INFO] | | +- (org.slf4j
jar:1.7.21:compile - version managed from 1.7.10; omitted for duplicate)
[INFO] | | +- (org.springframework.plugin
jar:1.2.0.RELEASE:compile - omitted for duplicate)
[INFO] | | \- (org.springframework.plugin
jar:1.2.0.RELEASE:compile - omitted for duplicate)
[INFO] | +- io.springfox
jar:2.6.1:compile
[INFO] | | +- (com.google.guava
jar:18.0:compile - omitted for duplicate)
[INFO] | | +- (com.fasterxml
jar:1.3.1:compile - omitted for duplicate)
[INFO] | | +- (org.slf4j
jar:1.7.21:compile - version managed from 1.7.10; omitted for duplicate)
[INFO] | | +- (org.springframework.plugin
jar:1.2.0.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework.plugin
jar:1.2.0.RELEASE:compile - omitted for duplicate)
[INFO] | | \- (io.springfox
jar:2.6.1:compile - omitted for duplicate)
[INFO] | +- (com.google.guava
jar:18.0:compile - omitted for ---<conflict 关键字>--- with 15.0)
[INFO] | +- com.fasterxml
jar:1.3.1:compile
[INFO] | +- org.slf4j
jar:1.7.21:compile
还没有评论,来说两句吧...