Scala sbt: Multiple dependencies in sbt

折月煮酒 提交于 2019-12-21 03:17:20

问题


I am a new user to Scala, following the way to create a scala sbt project.

https://www.youtube.com/watch?v=Ok7gYD1VbNw


After adding

libraryDependencies += "org.scalatest" % "scalatest_2.11" % "2.2.4" % "test"

to build.sbt, and refreshed the project, I got this msg.

[warn] Multiple dependencies with the same organization/name but different versions. To avoid conflict, pick one version:

[warn] * org.scala-lang:scala-reflect:(2.11.2, 2.11.7)

[warn] * org.scala-lang.modules:scala-xml_2.11:(1.0.2, 1.0.4)

And in build.sbt, thw word 'scalatest' is red that means it's an unsolved dependencies.

Should I change something in Project Setting, like scala sdk?

Best Regard!


回答1:


You could regard adding those dependencies:

libraryDependencies ++= Seq(
  "org.scala-lang" % "scala-reflect" % "2.11.7",
  "org.scala-lang.modules" % "scala-xml_2.11" % "1.0.4"
)

It forces compiler to choose concrete version of libraries. It solves problem for me.




回答2:


I was able to resolve this by excluding these from the scalatest dependency.

libraryDependencies ++= Seq(
  "org.scalatest" % "scalatest_2.11" % "2.2.4" % "test"
    exclude("org.scala-lang", "scala-reflect")
    exclude("org.scala-lang.modules", "scala-xml_2.11")
)


来源:https://stackoverflow.com/questions/34468460/scala-sbt-multiple-dependencies-in-sbt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!