jar包依赖冲突,版本不兼容会导致各种各样的问题。这里推荐一款sbt插件用于查找项目中的jar包依赖关系,通过该插件可以轻松的看出某个jar包依赖哪些jar,以及某个jar被哪些jar所依赖。此外该插件还可生成可视化图形用于查看依赖关系。
插件地址:https://github.com/jrudolph/sbt-dependency-graph
引用方式:
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.2")
使用命令:
Main Tasks dependencyTree: Shows an ASCII tree representation of the project's dependencies dependencyBrowseGraph: Opens a browser window with a visualization of the dependency graph (courtesy of graphlib-dot + dagre-d3). dependencyBrowseTree: Opens a browser window with a visualization of the dependency tree (courtesy of jstree). dependencyList: Shows a flat list of all transitive dependencies on the sbt console (sorted by organization and name) whatDependsOn <organization> <module> <revision>?: Find out what depends on an artifact. Shows a reverse dependency tree for the selected module. The <revision> argument is optional. dependencyLicenseInfo: show dependencies grouped by declared license dependencyStats: Shows a table with each module a row with (transitive) Jar sizes and number of dependencies dependencyGraphMl: Generates a .graphml file with the project's dependencies to target/dependencies-<config>.graphml. Use e.g. yEd to format the graph to your needs. dependencyDot: Generates a .dot file with the project's dependencies to target/dependencies-<config>.dot. Use graphviz to render it to your preferred graphic format. dependencyGraph: Shows an ASCII graph of the project's dependencies on the sbt console (only supported on sbt 0.13) ivyReport: Lets ivy generate the resolution report for you project. Use show ivyReport for the filename of the generated report
样例:
dependencyTree:按照树的方式列出所有的jar依赖关系
dependencyBrowseTree:绘制依赖关系图,以*.html文件保存,可在浏览器中打开查看
虚线是被替代的依赖
whatDependsOn: 查看指定jar被哪些jar所依赖。使用方式:whatDependsOn <org> <module> <version>
例如:whatDependsOn com.google.code.gson gson 2.8.0
===============================================
原文链接:jar包冲突排解方法(sbt) 转载请注明出处!
===============================================
---end