Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala sbt: Multiple dependencies in sbt

Tags:

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!

like image 335
Eason Caizhen Liu Avatar asked Dec 26 '15 04:12

Eason Caizhen Liu


People also ask

How do we specify library dependencies in sbt?

The libraryDependencies key Most of the time, you can simply list your dependencies in the setting libraryDependencies . It's also possible to write a Maven POM file or Ivy configuration file to externally configure your dependencies, and have sbt use those external configuration files.

Which is the correct way to add dependencies in sbt file?

If you have JAR files (unmanaged dependencies) that you want to use in your project, simply copy them to the lib folder in the root directory of your SBT project, and SBT will find them automatically.

Where are sbt dependencies stored?

All new SBT versions (after 0.7. x ) by default put the downloaded JARS into the . ivy2 directory in your home directory. If you are using Linux, this is usually /home/<username>/.


1 Answers

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.

like image 151
Bartłomiej Szałach Avatar answered Sep 22 '22 13:09

Bartłomiej Szałach