SBT:修复库依赖的驱逐警告是明智的

Pol*_*ase 16 scala sbt

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

通过将被驱逐的库的版本覆盖到最新版本.这会迫使SBT坚持使用被覆盖的版本吗?SBT是否仍会通知我们将来有更新的版本?

驱逐警告示例(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
Run Code Online (Sandbox Code Playgroud)

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

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

jki*_*ead 22

如果这些警告是您在代码中直接使用的依赖项,那么您一定要将升级后的版本添加到您的代码中libraryDependencies.

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

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