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:springfox-swagger2:jar:2.6.1:compile
[INFO] |  +- io.swagger:swagger-annotations:jar:1.5.10:compile
[INFO] |  +- io.swagger:swagger-models:jar:1.5.10:compile
[INFO] |  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.1:compile (version managed from 2.4.5)
[INFO] |  |  +- (org.slf4j:slf4j-api:jar:1.7.21:compile - version managed from 1.7.10; omitted for duplicate)
[INFO] |  |  \- (io.swagger:swagger-annotations:jar:1.5.10:compile - omitted for duplicate)
[INFO] |  +- io.springfox:springfox-spi:jar:2.6.1:compile
[INFO] |  |  \- io.springfox:springfox-core:jar:2.6.1:compile
[INFO] |  |     +- (com.google.guava:guava:jar:18.0:compile - omitted for duplicate)
[INFO] |  |     +- (com.fasterxml:classmate:jar:1.3.1:compile - omitted for duplicate)
[INFO] |  |     +- (org.slf4j:slf4j-api:jar:1.7.21:compile - version managed from 1.6.3; omitted for duplicate)
[INFO] |  |     +- (org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile - omitted for duplicate)
[INFO] |  |     \- (org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile - omitted for duplicate)
[INFO] |  +- io.springfox:springfox-schema:jar:2.6.1:compile
[INFO] |  |  +- (io.springfox:springfox-core:jar:2.6.1:compile - omitted for duplicate)
[INFO] |  |  \- (io.springfox:springfox-spi:jar:2.6.1:compile - omitted for duplicate)
[INFO] |  +- io.springfox:springfox-swagger-common:jar:2.6.1:compile
[INFO] |  |  +- (io.swagger:swagger-annotations:jar:1.5.10:compile - omitted for duplicate)
[INFO] |  |  +- (io.swagger:swagger-models:jar:1.5.10:compile - omitted for duplicate)
[INFO] |  |  +- (io.springfox:springfox-spi:jar:2.6.1:compile - omitted for duplicate)
[INFO] |  |  +- (io.springfox:springfox-schema:jar:2.6.1:compile - omitted for duplicate)
[INFO] |  |  +- (io.springfox:springfox-spring-web:jar:2.6.1:compile - omitted for duplicate)
[INFO] |  |  +- (com.google.guava:guava:jar:18.0:compile - omitted for duplicate)
[INFO] |  |  +- (com.fasterxml:classmate:jar:1.3.1:compile - omitted for duplicate)
[INFO] |  |  +- (org.slf4j:slf4j-api:jar:1.7.21:compile - version managed from 1.7.10; omitted for duplicate)
[INFO] |  |  +- (org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile - omitted for duplicate)
[INFO] |  |  \- (org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile - omitted for duplicate)
[INFO] |  +- io.springfox:springfox-spring-web:jar:2.6.1:compile
[INFO] |  |  +- (com.google.guava:guava:jar:18.0:compile - omitted for duplicate)
[INFO] |  |  +- (com.fasterxml:classmate:jar:1.3.1:compile - omitted for duplicate)
[INFO] |  |  +- (org.slf4j:slf4j-api:jar:1.7.21:compile - version managed from 1.7.10; omitted for duplicate)
[INFO] |  |  +- (org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile - omitted for duplicate)
[INFO] |  |  +- (org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile - omitted for duplicate)
[INFO] |  |  \- (io.springfox:springfox-spi:jar:2.6.1:compile - omitted for duplicate)
[INFO] |  +- (com.google.guava:guava:jar:18.0:compile - omitted for ---<conflict 关键字>--- with 15.0)
[INFO] |  +- com.fasterxml:classmate:jar:1.3.1:compile
[INFO] |  +- org.slf4j:slf4j-api:jar:1.7.21:compile
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值