添加
后foo(a: number): Promise<boolean> {
return doSomething(a).then((b) => {
return doAnotherThing(b);
}).then((c) => {
return true;
});
}
到 build.sbt ,并刷新了项目,我收到了这个消息。
SBT项目导入
[warn]具有相同组织/名称的多个依赖项但是 不同的版本。为避免冲突,请选择一个版本:
[warn] * org.scala-lang.modules:scala-xml_2.11:(1.0.5,1.0.4)
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test"
解决了这个问题。但是,我不想从scalatest中排除scala-xml_2.11版本1.0.5,而是希望force the scala compiler使用scala-xml_2.11版本1.0.5而不是版本1.0.4。 (我研究了https://mvnrepository.com的版本。)因此我尝试用libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.0" % "test"
exclude("org.scala-lang", "scala-reflect")
exclude("org.scala-lang.modules", "scala-xml_2.11")
)
代替
scalaVersion := "2.11.8"
然而这导致
SBT项目导入
[warn]依赖的二进制版本(2.11) org.scala琅#阶-反映; 2.11.8
默认情况下[warn] #myproject $ sources_javadoc_2.10; 1.0不同 来自项目(2.10)中的Scala二进制版本。
[warn]依赖的二进制版本(2.11) org.scala琅#阶库; 2.11.8
默认情况下[warn] #myproject $ sources_javadoc_2.10; 1.0不同 来自项目(2.10)中的Scala二进制版本。
[warn]具有相同组织/名称的多个依赖项但是 不同的版本。为避免冲突,请选择一个版本:
[warn] * org.scala-lang:scala-library:(2.11.8,2.10.4)
[warn] * org.scala-lang:scala-reflect:(2.11.8,2.10.4)
[警告] [未通过] com.artima.supersafe#supersafe_2.10.4; 1.1.0 supersafe_2.10.4.jar(SRC)! (0毫秒)
[警告] ====本地:尝试
[警告]
/home/user/.ivy2/local/com.artima.supersafe/supersafe_2.10.4/1.1.0/srcs/supersafe_2.10.4-sources.jar[warn] ==== activator-local:试过[warn] /Development/Activator/activator-dist-1.3.10/repository/com.artima.supersafe/supersafe_2.1 ... (显示气球)
我应该做什么?
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % "2.11.8",
"org.scala-lang.modules" % "scala-xml_2.11" % "1.0.5"
)
[warn]具有相同组织/名称的多个依赖项但是 不同的版本。为避免冲突,请选择一个版本:[警告] * org.scala-lang.modules:scala-xml_2.11:(1.0.5,1.0.4)
scalaVersion := "2.11.8"
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang.modules" %% "scala-xml" % "1.0.5"
)
// ScalaTest
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test"
错误:导入SBT项目时出错:
...[info] Resolving org.scala-sbt#run;0.13.8 ... [info] Resolving org.scala-sbt#task-system;0.13.8 ... [info] Resolving org.scala-sbt#tasks;0.13.8 ... [info] Resolving org.scala-sbt#tracking;0.13.8 ... [info] Resolving org.scala-sbt#cache;0.13.8 ... [info] Resolving org.scala-sbt#testing;0.13.8 ... [info] Resolving org.scala-sbt#test-agent;0.13.8 ... [info] Resolving org.scala-sbt#test-interface;1.0 ... [info] Resolving org.scala-sbt#main-settings;0.13.8 ... [info] Resolving org.scala-sbt#apply-macro;0.13.8 ... [info] Resolving org.scala-sbt#command;0.13.8 ... [info] Resolving org.scala-sbt#logic;0.13.8 ... [info] Resolving org.scala-sbt#precompiled-2_8_2;0.13.8 ... [info] Resolving org.scala-sbt#precompiled-2_9_2;0.13.8 ... [info] Resolving org.scala-sbt#precompiled-2_9_3;0.13.8 ... [trace] Stack trace suppressed: run 'last *:update' for the full output. [trace] Stack trace suppressed: run 'last :ssExtractDependencies' for the full output. [error] (:update) sbt.ResolveException: unresolved dependency: org.scala-lang.modules#scala-xml_2.11_2.11;1.0.5: not found [error] (*:ssExtractDependencies) sbt.ResolveException: unresolved dependency: org.scala-lang.modules#scala-xml_2.11_2.11;1.0.5: not found [error] Total time: 4 s, completed 01.10.2016 17:46:55
scalaVersion := "2.11.8"
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang.modules" %% "scala-xml_2.11" % "1.0.5"
)
// ScalaTest
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test"
[warn]具有相同组织/名称的多个依赖项但是 不同的版本。为避免冲突,请选择一个版本:[警告] * org.scala-lang.modules:scala-xml_2.11:(1.0.5,1.0.4)
scalaVersion := "2.11.8"
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang.modules" %% "scala-xml" % "1.0.5"
)
// ScalaTest
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.0" % "test"
exclude("org.scala-lang", "scala-reflect")
exclude("org.scala-lang.modules", "scala-xml")
)
build.sbt
答案 0 :(得分:1)
排除特定传递依赖的方法是:
运行sbt evicted
以确定哪些项目依赖项正在过时的库中,让我们假设有问题的库是:com.typesafe.slick
。
添加以下排除(括号很重要):
("com.typesafe" %% "slick" % "3.1.1").exclude("org.scala-lang.modules", "scala-xml_2.11")
正常添加此项,就像列出依赖项一样。
这将阻止sbt包含任何版本的scala-xml
作为Slick的传递依赖而进入。
答案 1 :(得分:0)
不要替换;您需要scalaVersion
和libraryDependencies
。
虽然使用
scalaVersion := "2.11.8"
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang.modules" %% "scala-xml" % "1.0.5"
)
以避免在最终更改scalaVersion
时出现错误。
删除scalaVersion
后,您将获得默认scalaVersion := "2.10.4"
(至少包含您的SBT版本/设置),但您的libraryDependencies
仍需要2.11。