SBT:修复库依赖项的驱逐警告是否明智 [英] SBT: is it wise to fix eviction warnings of library dependencies

查看:45
本文介绍了SBT:修复库依赖项的驱逐警告是否明智的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

修复 SBT 驱逐警告消息是个好主意吗?

通过将被驱逐库的版本覆盖为最新版本.这会迫使 SBT 终生坚持使用覆盖的版本吗?SBT 还会通知我们将来有更新的版本吗?

驱逐警告示例 (SBT 0.13.13)

[warn] 您的库依赖项之间可能存在不兼容.[警告] 以下是一些被驱逐的库:[警告] * com.chuusai:shapeless_2.11:1.2.4 ->2.3.2[警告] * org.postgresql:postgresql:9.4-1201-jdbc41 ->9.4.1208.jre7[警告] * jline:jline:0.9.94 ->2.12.1[warn] 运行evicted"查看详细的驱逐警告

通过在 build.sbt 的末尾添加这个来删除警告.按照 SBT 文档中的说明驱逐警告

dependencyOverrides ++= Set("org.postgresql" % "postgresql" % "9.4.1208.jre7","com.chuusai" %% "shapeless" % "2.3.2","jline" % "jline" % "2.12.1")

解决方案

如果这些警告是针对您直接在代码中使用的依赖项,那么您绝对应该将升级版本添加到您的 libraryDependencies.

对于驱逐的传递依赖项(那些依赖项仅由您自己的依赖项直接使用),最好简单地保留警告.这会为您提供有关依赖项中可能存在的不兼容性的文档,并可以帮助您调试由于此类不兼容性而出现的运行时问题.

请记住,设置 dependencyOverrides 只会隐藏警告,并不能保证您的库与您设置的版本之间的兼容性.

Is it a good idea to fix SBT eviction warning messages?

By overriding the version of the evicted libraries to the latest. Would that force SBT to stick with the overridden version for life? Would SBT still notify us that there are newer versions in the future?

Example of eviction warnings (SBT 0.13.13)

[warn] There may be incompatibilities among your library dependencies.
[warn] Here are some of the libraries that were evicted:
[warn]  * com.chuusai:shapeless_2.11:1.2.4 -> 2.3.2
[warn]  * org.postgresql:postgresql:9.4-1201-jdbc41 -> 9.4.1208.jre7
[warn]  * jline:jline:0.9.94 -> 2.12.1
[warn] Run 'evicted' to see detailed eviction warnings

Remove the warnings by adding this at the end of build.sbt. Following the instructions in SBT Documentation Eviction warning

dependencyOverrides ++= Set(
  "org.postgresql" % "postgresql" % "9.4.1208.jre7",
  "com.chuusai" %% "shapeless" % "2.3.2",
  "jline" % "jline" % "2.12.1"
)

解决方案

If these warnings are for dependencies you use directly in your code, you should definitely add the upgraded version to your libraryDependencies.

For evicted transitive dependencies (those dependencies only used directly by your own dependencies), it's likely best to simply leave the warnings in place. This provides documentation to you about possible incompatibilities in your dependencies, and could help you debug runtime problems that arise due to such incompatibilities.

Remember, setting dependencyOverrides merely hides the warning, it doesn't guarantee compatibility between your libraries and the version you set.

这篇关于SBT:修复库依赖项的驱逐警告是否明智的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆