21

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!

Community
  • 1
  • 1
Eason Caizhen Liu
  • 459
  • 1
  • 5
  • 12
  • as soon as it's warining it should not be a problem. check for `error`s. If there are any - print them here. – vvg Dec 26 '15 at 08:23
  • If you use IntellJ Idea, anything can be red in `build.sbt`, but it still will compile. IDE's parser sometimes cannot parse stuff (scala code as well), so usually you can just ignore red stuff as long as it compiles. The same probably is true for other IDEs. – Archeg Dec 26 '15 at 09:16
  • @Archeg If my configure is right, I can run the test file, right? At the moment, I even can't have the 'run' in IDE while right-click the file. – Eason Caizhen Liu Dec 28 '15 at 07:44
  • You've posted just a warning, which probably has nothing to do with not-workable state. What does it say when you try to run it? – Archeg Dec 28 '15 at 09:53

2 Answers2

25

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.

Bartłomiej Szałach
  • 2,393
  • 3
  • 30
  • 50
  • 2
    I wonder why Idea cannot figure it out itself with `scalaVersion := "2.11.7"` in `build.sbt` – Ivan Balashov Jul 22 '16 at 06:15
  • 1
    This works most of the time however I'm having problem with versions `1.0.4` and `1.0.5` of `org.scala-lang.modules:scala-xml`. I've gone as far as clearing them from Ivy cache but with no positive outcome. – ZbyszekKr Sep 01 '16 at 20:08
8

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")
)
Dillon Ryan Redding
  • 1,213
  • 12
  • 17