21
votes

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!

2
as soon as it's warining it should not be a problem. check for errors. If there are any - print them here.vvg
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
@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
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

2 Answers

25
votes

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.

7
votes

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")
)