maven排查冲突jar包

  • maven排查冲突jar包已关闭评论
  • 1,505次阅读
  • A+
所属分类:Maven

使用maven构建项目,如果项目模块比较多的话,有可能会出现jar文件冲突,如果不排查重复jar包项目就会出现编译问题。
我们排查jar文件冲突可以使用maven自带的命令,将所有依赖的jar文件打印出来,或者打印至txt文件中进行排查。

maven打印依赖包信息至文件中

在项目模块目录下使用如下命令,将依赖信息打印至tree.txt文件中。

mvn dependency:tree -Dverbose > 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

  • 我的微信
  • 加好友一起交流!
  • weinxin
  • 微信公众号
  • 关注公众号获取分享资源!
  • weinxin