2017-02-28 59 views
5

修复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 

通过在build.sbt的末尾添加该删除警告。继SBT文档Eviction warning

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

回答

10

的说明。如果这些警告是您在代码中直接使用的依赖,你一定要升级后的版本添加到您的libraryDependencies

对于被驱逐的传递依赖关系(这些依赖关系只能由您自己的依赖关系直接使用),最好只保留警告。这为您提供了关于您的依赖关系中可能的不兼容问题的文档,并且可以帮助您调试由于此类不兼容问题而导致的运行时问题。

请记住,设置dependencyOverrides只是隐藏警告,它不能保证您的库和您设置的版本之间的兼容性。