Sbt 排除依赖冲突详细解析

前端之家收集整理的这篇文章主要介绍了Sbt 排除依赖冲突详细解析前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1.Sbt 依赖树

参考:
dependencyGraph sbt plugin
https://github.com/jrudolph/sbt-dependency-graph

安装插件
建立文件:./.sbt/1.0/plugins/plugins.sbt
添加内容:addSbtPlugin(“net.virtual-void” % “sbt-dependency-graph” % “0.9.0”)

插件启动
sbt:graPHPlatform> dependencyTree
其他命令:https://github.com/jrudolph/sbt-dependency-graph#main-tasks

问题:
项目中要的是hbase1.2.6版本的包,确出现了hbase1.1.1,原因是hive-jdbc和hive-cli间接依赖hbase1.1.1
sbt的依赖包如下所示:

"org.apache.hbase" % "hbase-client" % "1.2.6","org.apache.hbase" % "hbase-common" % "1.2.6","org.apache.hbase" % "hbase-server" % "1.2.6","org.apache.hbase" % "hbase-protocol" % "1.2.6","org.apache.hive" % "hive-jdbc" % "2.3.2","org.apache.hive" % "hive-cli" % "2.3.2",

项目中依赖截图如下所示:
idea–>File–>Project Structure–>Libraries

解决依赖:
1)使用依赖树:sbt->project project_name->dependencyTree
2)查看相互依赖:sbt->project project_name->whatDependsOn org.apache.hbase hbase-annotations 1.1.1

依赖从下往上看“com.jd.jr:graph_importer_2.11:1.0-SNAPSHOT”依赖–>“org.apache.hive:hive-cli:2.3.2”依赖–>“org.apache.hive:hive-service:2.3.2”依赖–>“org.apache.hive:hive-llap-server:2.3.2”依赖–>“org.apache.hbase:hbase-server:1.1.1”

找到问题了,需要在“org.apache.hive:hive-cli:2.3.2”排除“org.apache.hbase:hbase-server:1.1.1”

sbt:graph_importer> whatDependsOn org.apache.hbase hbase-server 1.1.1
[info] org.apache.hbase:hbase-server:1.1.1 (evicted by: 1.2.6)
[info]   +-com.jd.jr:graph_importer_2.11:1.0-SNAPSHOT [S]
[info]   +-org.apache.hive:hive-llap-server:2.3.2
[info]     +-org.apache.hive:hive-service:2.3.2
[info]       +-org.apache.hive:hive-cli:2.3.2
[info]       | +-com.jd.jr:graph_importer_2.11:1.0-SNAPSHOT [S]
[info]       |
[info]       +-org.apache.hive:hive-jdbc:2.3.2
[info]         +-com.jd.jr:graph_importer_2.11:1.0-SNAPSHOT [S]
[info]

3)其余三个不需要的Jar包参考第二步
sbt依赖的处理后展示

"org.apache.hbase" % "hbase-client" % "1.2.6","org.apache.hive" % "hive-jdbc" % "2.3.2"
    exclude("org.apache.hbase","hbase-protocol")
    exclude("org.apache.hbase","hbase-client")
    exclude("org.apache.hbase","hbase-common")
    exclude("org.apache.hbase","hbase-service"),"org.apache.hive" % "hive-cli" % "2.3.2"
    exclude("org.apache.hbase",

4)sbt中先“clean”再“compile”.(其中compile包括了update)
项目中依赖截图如下所示:

原文链接:https://www.f2er.com/javaschema/282154.html

猜你在找的设计模式相关文章