I had some waitQueue size limit exceeded issues in the past with my http4s-blaze-client#0.21.0-M6. As per the recommendation I am trying to upgrade my http4s version from 0.21.0-M6 to 0.21.33. Now I am facing the below compilation error in the code:
Symbol 'type cats.package.MonadThrow' is missing from the classpath.
This symbol is required by 'value org.http4s.Media.F'.
Make sure that type MonadThrow is in your classpath and check for conflicting dependencies with -Ylog-classpath.
A full rebuild may help if 'Media.class' was compiled against an incompatible version of cats.package.
could not find implicit value for parameter F: cats.MonadThrow[[_]F[_]]
parsedRequest <- authedReq.req.as[CreateScheduleRequest]
I referred to https://http4s.org/versions.html and it looks like I am using all the compatible versions. The only dependency I changed was of the http4s. Rest of the dependencies were unchanged and were working fine with http4s#0,21,0-M6. I am new to http4s and cats-effect. Could someone please suggest what can be done to fix the above issue?
Below is the summary of my dependencies:
val mqtt = "org.eclipse.paho" % "org.eclipse.paho.client.mqttv3" % "1.2.2"
val doobie = "org.tpolecat" %% "doobie-core" % "0.8.8"
val doobieJDBC = "org.tpolecat" %% "doobie-postgres" % "0.8.8"
val doobieCP = "org.tpolecat" %% "doobie-hikari" % "0.8.8"
val flyway = "org.flywaydb" % "flyway-core" % "6.2.2"
//common
val http4sDsl = "org.http4s" %% "http4s-dsl" % "0.21.33" //previously "0.21.0-M6"
val http4sServer = "org.http4s" %% "http4s-blaze-server" % "0.21.33" //previously "0.21.0-M6"
val http4sClient = "org.http4s" %% "http4s-blaze-client" % "0.21.33" //previously "0.21.0-M6"
val http4sCirce = "org.http4s" %% "http4s-circe" % "0.21.33" //previously "0.21.0-M6"
val chimney = "io.scalaland" %% "chimney" % "0.4.1"
val catsEffect = "org.typelevel" %% "cats-effect" % "2.1.0"
val mouse = "org.typelevel" %% "mouse" % "0.24"
val circeParser = "io.circe" %% "circe-parser" % "0.13.0"
val circeGeneric = "io.circe" %% "circe-generic" % "0.13.0"
val circeGenExt = "io.circe" %% "circe-generic-extras" % "0.13.0"
val config = "com.typesafe" % "config" % "1.4.0"
val logback = "ch.qos.logback" % "logback-classic" % "1.2.3"
//test
val moquette = "io.moquette" % "moquette-broker" % "0.11"
val doobieH2 = "org.tpolecat" %% "doobie-h2" % "0.8.8"
val scalaTest = "org.scalatest" %% "scalatest" % "3.2.0-M2"
scalaVersion = "2.13.1"
Below is the http4s route class that is giving the compilation error:
import java.time.LocalDateTime
import cats.effect._
import cats.implicits._
import io.circe.generic.auto._
import org.http4s._
import org.http4s.dsl._
class ScheduleRoute[F[_]: Effect] extends Http4sDsl[F] with HttpMarshalling with HttpResponseHandler[F] {
final def serve(service: ScheduleServiceAlgebra[F]): AuthedService[User, F] = AuthedService{
case authedReq # POST -> Root / "buildings" / InstallationUuidVar(installationUuid) / "entries" as user =>
val io = for {
parsedRequest <- authedReq.req.as[CreateScheduleRequest]
validRequest <- parsedRequest.validate
result <- service.createSchedule(installationUuid, validRequest, user)
now <- Sync[F].delay(LocalDateTime.now(java.time.ZoneId.of("UTC")))
} yield result.withNextOccurrenceTime(now)
io.result
}
}
P.S. I ran sbt evicted command and see the following. Does it mean I need to update some of the dependencies?
[warn] Found version conflict(s) in library dependencies; some are suspected to be binary incompatible:
[warn]
[warn] * org.log4s:log4s_2.13:1.10.0 is selected over 1.9.0
[warn] +- org.http4s:http4s-core_2.13:0.21.33 () (depends on 1.10.0)
[warn] +- org.http4s:blaze-core_2.13:0.14.18 (depends on 1.9.0)
[warn]
[warn] * co.fs2:fs2-core_2.13:2.5.9 is selected over 2.2.2
[warn] +- co.fs2:fs2-io_2.13:2.5.9 (depends on 2.5.9)
[warn] +- org.http4s:http4s-core_2.13:0.21.33 () (depends on 2.5.9)
[warn] +- org.http4s:jawn-fs2_2.13:1.0.0 (depends on 2.2.2)
[warn]
[warn] Run 'evicted' to see detailed eviction warnings
[info] Here are other depedency conflicts that were resolved:
[info]
[info] * org.typelevel:jawn-parser_2.13:1.0.1 is selected over 1.0.0
[info] +- io.circe:circe-jawn_2.13:0.13.0 () (depends on 1.0.0)
[info] +- org.http4s:http4s-jawn_2.13:0.21.33 () (depends on 1.0.0)
[info] +- org.http4s:jawn-fs2_2.13:1.0.0 (depends on 1.0.0)
[info]
[info] * org.slf4j:slf4j-api:1.7.31 is selected over 1.7.30
[info] +- org.log4s:log4s_2.13:1.10.0 (depends on 1.7.30)
[info] +- org.http4s:http4s-core_2.13:0.21.33 () (depends on 1.7.30)
Related
I'm newish to SBT and am not sure what to do about a rather scary warning from the evicted task: [warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
The full task output is...
sbt:Sprout> evicted
[info] Updating ...
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[warn] Found version conflict(s) in library dependencies; some are suspected to be binary incompatible:
[warn] * org.scala-lang.modules:scala-xml_2.12:1.1.0 is selected over 1.0.6
[warn] +- org.json4s:json4s-xml_2.12:3.6.3 (depends on 1.1.0)
[warn] +- org.scalatra:scalatra_2.12:2.6.5 (depends on 1.0.6)
[warn] +- com.typesafe.play:twirl-api_2.12:1.3.13 (depends on 1.0.6)
[info] Here are other dependency conflicts that were resolved:
[info] * org.json4s:json4s-core_2.12:3.6.5 is selected over 3.6.3
[info] +- org.json4s:json4s-jackson_2.12:3.6.5 (depends on 3.6.5)
[info] +- org.json4s:json4s-xml_2.12:3.6.3 (depends on 3.6.3)
[info] +- org.scalatra:scalatra-json_2.12:2.6.5 (depends on 3.6.3)
[info] * org.json4s:json4s-scalap_2.12:3.6.5 is selected over 3.6.3
[info] +- org.json4s:json4s-core_2.12:3.6.5 (depends on 3.6.5)
[info] +- org.json4s:json4s-core_2.12:3.6.3 (depends on 3.6.3)
[info] * org.json4s:json4s-ast_2.12:3.6.5 is selected over 3.6.3
[info] +- org.json4s:json4s-core_2.12:3.6.5 (depends on 3.6.5)
[info] +- org.json4s:json4s-core_2.12:3.6.3 (depends on 3.6.3)
[success] Total time: 1 s, completed Apr 13, 2019 12:53:54 PM
"suspected binary incompatible" sound serious. Is it?
Is there just some exclude that I can tag onto the dependencies to get the dependencies in agreement as to what the correct versions are?
The SBT dependencies are like...
libraryDependencies ++= Seq(
"org.scalatra" %% "scalatra" % ScalatraVersion exclude("org.slf4j","slf4j-api"),
"org.scalatra" %% "scalatra-scalatest" % ScalatraVersion % "test",
"org.slf4j" % "slf4j-api" % "1.7.26",
"ch.qos.logback" % "logback-classic" % "1.2.3" % "runtime",
"org.eclipse.jetty" % "jetty-webapp" % "9.4.9.v20180320" % "container",
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
"org.scalatra" %% "scalatra-json" % ScalatraVersion,
"org.json4s" %% "json4s-jackson" % "3.6.5",
)
This warning appears because org.scalatra:scalatra_2.12:2.6.5 & com.typesafe.play:twirl-api_2.12:1.3.13 depends on org.scala-lang.modules:scala-xml_2.12:1.0.6, but org.json4s:json4s-xml_2.12:3.6.3 uses org.scala-lang.modules:scala-xml_2.12:1.1.0
In order to hide this warning, you can use dependencyOverrides:
dependencyOverrides += "org.scala-lang.modules" % "scala-xml_2.12" % "1.0.6"
Again, it will just hide the warning, but it doesn't guarantee compatibility between your libraries and the version you set.
Ideally we should resolve evection warnings instead of override, if at all possible, due to potentially introducing hard-to-trace bugs. In this case it is possible if we are willing to drop scalatra and json4s-jackson versions to 2.6.4 and 3.5.2, respectively, like so:
val ScalatraVersion = "2.6.4"
libraryDependencies ++= Seq(
"org.scalatra" %% "scalatra" % ScalatraVersion exclude("org.slf4j","slf4j-api"),
"org.scalatra" %% "scalatra-scalatest" % ScalatraVersion % "test",
"org.slf4j" % "slf4j-api" % "1.7.26",
"ch.qos.logback" % "logback-classic" % "1.2.3" % "runtime",
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
"org.scalatra" %% "scalatra-json" % ScalatraVersion,
"org.json4s" %% "json4s-jackson" % "3.5.2",
)
I am trying to create a test class to my project that uses Play 2.6 and Scala 2.12. I've imported the scalatest lib:
libraryDependencies += guice
libraryDependencies += evolutions
libraryDependencies += jdbc
libraryDependencies += filters
libraryDependencies += "com.h2database" % "h2" % "1.4.194"
libraryDependencies += "com.typesafe.play" %% "anorm" % "2.5.3"
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "3.1.0" % Test
libraryDependencies += "org.scala-lang" % "scala-actors" % "2.10.0-M7" % "test"
libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.4"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.4" % "test"
libraryDependencies += "com.typesafe.play" %% "play-slick" % "3.0.0"
libraryDependencies += "com.typesafe.play" %% "play-slick-evolutions" % "3.0.0"
libraryDependencies += "org.xerial" % "sqlite-jdbc" % "3.19.3"
And my compiler says that ShouldMatchers does not exist in the scalatest lib.
class RackRepositorySpec extends PlaySpec with GuiceOneAppPerTest with Injecting {
val database = Databases(
driver = "org.sqlite.JDBC",
url = "jdbc:sqlite:development.db",
name = "default",
config = Map(
"username" -> "",
"password" -> ""
)
)
val guice = new GuiceInjectorBuilder()
.overrides(bind[Database].toInstance(database))
.injector()
val defaultDbProvider = guice.instanceOf[DatabaseConfigProvider]
def beforeAll() = Evolutions.applyEvolutions(database)
def afterAll() = {
// Evolutions.cleanupEvolutions(database)
database.shutdown()
}
Evolution(
1,
"create table test (id bigint not null, name varchar(255));",
"drop table test;"
)
}
I got the last version of the Scalatest but it seems that this class does not exist anymore. I am following this example: https://dzone.com/articles/getting-started-play-21-scala
Does anyone have another example to built a Scala test for Slick in-memory database?
[info] RackRepositorySpec:
[info] models.RackRepositorySpec *** ABORTED ***
[info] com.google.inject.ConfigurationException: Guice configuration errors:
[info]
[info] 1) No implementation for play.api.db.slick.DatabaseConfigProvider was bound.
[info] while locating play.api.db.slick.DatabaseConfigProvider
[info]
[info] 1 error
[info] at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1045)
[info] at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1004)
[info] at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1054)
[info] at play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:409)
[info] at play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:404)
[info] at play.api.inject.ContextClassLoaderInjector.$anonfun$instanceOf$2(Injector.scala:117)
[info] at play.api.inject.ContextClassLoaderInjector.withContext(Injector.scala:126)
[info] at play.api.inject.ContextClassLoaderInjector.instanceOf(Injector.scala:117)
[info] at models.RackRepositorySpec.<init>(RackRepositorySpec.scala:26)
[info] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
Kind Regards,
Felipe
I did use Slick for one of my Scala projects and I had Postgress as my database. For unit testing purposed, I created a test h2 in memory database which is populated during unit test and teared down after the tests are done.
You can have a look at the sample here:
https://github.com/joesan/plant-simulator/blob/master/test/com/inland24/plantsim/services/database/PowerPlantDBServiceSpec.scala
What I also wanted to do is to have some sort of automation where in iI wanted to populate the h2 data files and keep them forever for the next cycles of unit testing.
ShouldMatchers were deprecated in version 2 and removed in version 3. Use Matchers or MustMatchers instead.
See the release notes.
I need to plot my dataframe using WISP. I am using Apache Sprak in Scala. However it seems that it can not accept a dataframe.
+-----+--------------------+------------------+
|label| features| prediction|
+-----+--------------------+------------------+
| 101|[1.497846976E9,10...|101.22752534884378|
| 101|[1.497846976E9,10...|101.22752534884378|
| 101|[1.497846976E9,10...|101.22752534884378|
| 101|[1.497846976E9,10...|101.22752534884378|
| 101|[1.497846976E9,10...|101.22752534884378|
+-----+--------------------+------------------+
I also tried to change my datarame to Seq using the following code but, it does't work.
import org.apache.spark.sql.functions.{collect_list, collect_set}
val label=predictions.groupBy($"label").agg(collect_list($"label").alias("label"))
val predicted= predictions.groupBy($"prediction").agg(collect_list($"prediction").alias("prediction"))
line(predicted)
It shows me the following error:
Error:(157, 10) type mismatch;
found : org.apache.spark.sql.DataFrame
(which expands to) org.apache.spark.sql.Dataset[org.apache.spark.sql.Row]
required: com.quantifind.charts.repl.IterablePair[?,?,?,?]
line(predicted)
Is there any trick to plot a dataframe like below using WISP? Thanks in advance.
UPDATE:
According to answer number one, As I try to install vegas libraries, I got an error:
Error:Error while importing SBT project:<br/>...<br/><pre>[warn] ==== MapR Repository: tried
[warn] http://repository.mapr.com/maven/com/github/aishfenton/vegas-spark_2.10_2.11/0.2.0/vegas-spark_2.10_2.11-0.2.0.pom
[info] Resolving org.scala-lang#scala-compiler;2.11.8 ...
[info] Resolving org.scala-lang.modules#scala-xml_2.11;1.0.4 ...
[info] Resolving org.scala-lang.modules#scala-parser-combinators_2.11;1.0.4 ...
[info] Resolving jline#jline;2.12.1 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.github.aishfenton#vegas-spark_2.10_2.11;0.2.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] com.github.aishfenton:vegas-spark_2.10_2.11:0.2.0 (/Users/saeedtkh/Desktop/ML_Alpha/build.sbt#L15-34)
[warn] +- ml:ml_2.11:1.0
[trace] Stack trace suppressed: run 'last *:ssExtractDependencies' for the full output.
[trace] Stack trace suppressed: run 'last *:update' for the full output.
[error] (*:ssExtractDependencies) sbt.ResolveException: unresolved dependency: com.github.aishfenton#vegas-spark_2.10_2.11;0.2.0: not found
[error] (*:update) sbt.ResolveException: unresolved dependency: com.github.aishfenton#vegas-spark_2.10_2.11;0.2.0: not found
[error] Total time: 27 s, completed Sep 22, 2017 1:06:23 PM</pre><br/>See complete log in file:/Users/saeedtkh/Library/Logs/IntelliJIdea2017.1/sbt.last.log
My bulid.sbt file is:
name := "ML"
version := "1.0"
scalaVersion := "2.11.8"
retrieveManaged := true
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
resolvers += "MapR Repository" at "http://repository.mapr.com/maven/"
libraryDependencies ++= Seq(
"co.theasi" %% "plotly" % "0.2.0",
"org.apache.commons" % "commons-csv" % "1.1",
"org.apache.spark" %% "spark-core" % "2.0.2",
"org.apache.spark" %% "spark-core" % "2.0.2",
"org.apache.spark" %% "spark-sql" % "2.0.2",
"org.apache.spark" %% "spark-hive" % "2.0.2",
"org.apache.spark" %% "spark-streaming" % "2.0.2",
"org.apache.spark" %% "spark-mllib" % "2.0.2",
"org.apache.spark" %% "spark-mllib" % "2.0.2",
"org.scalanlp" %% "breeze" % "0.11.2",
"org.scalanlp" %% "breeze-natives" % "0.11.2",
"org.scalanlp" %% "breeze-viz" % "0.11.2",
"com.quantifind" %% "wisp" % "0.0.4"
// https://mvnrepository.com/artifact/com.github.aishfenton/vegas-spark_2.10
//"com.github.aishfenton" %% "vegas-spark_2.10" % "0.2.0"
)
What exactly are you trying to plot? Have you tried using Vegas? Vegas plotting library for Scala
An example for getting histograms of a dataframe column:
Add the following lines to your build file.
"org.vegas-viz" %% "vegas" % "0.3.9",
"org.vegas-viz" %% "vegas-spark" % "0.3.9"
An example code
import vegas._
import vegas.render.WindowRenderer._
import vegas.sparkExt._
val plot = Vegas("approval date").
withDataFrame(castedDf).
mark(Bar).
encodeX("columnName", Quant, bin=Bin(maxbins=20.0), sortOrder=SortOrder.Desc).
show
After adding
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test"
to build.sbt, and refreshed the project, I got this msg.
SBT project import
[warn] Multiple dependencies with the same organization/name but
different versions. To avoid conflict, pick one version:
[warn] * org.scala-lang.modules:scala-xml_2.11:(1.0.5, 1.0.4)
Changing the above to
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.0" % "test"
exclude("org.scala-lang", "scala-reflect")
exclude("org.scala-lang.modules", "scala-xml_2.11")
)
solves the issue. However, instead of excluding scala-xml_2.11 version 1.0.5 from scalatest, I would like to force the scala compiler to use scala-xml_2.11 version 1.0.5 instead of version 1.0.4. (I researched the versions at https://mvnrepository.com.) Thus I tried substituting scalaVersion := "2.11.8" for
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % "2.11.8",
"org.scala-lang.modules" % "scala-xml_2.11" % "1.0.5"
)
This however results in
SBT project import
[warn] Binary version (2.11) for dependency
org.scala-lang#scala-reflect;2.11.8
[warn] in default#myproject$sources_javadoc_2.10;1.0 differs
from Scala binary version in project (2.10).
[warn] Binary version (2.11) for dependency
org.scala-lang#scala-library;2.11.8
[warn] in default#myproject$sources_javadoc_2.10;1.0 differs
from Scala binary version in project (2.10).
[warn] Multiple dependencies with the same organization/name but
different versions. To avoid conflict, pick one version:
[warn] * org.scala-lang:scala-library:(2.11.8, 2.10.4)
[warn] * org.scala-lang:scala-reflect:(2.11.8, 2.10.4)
[warn] [FAILED ]
com.artima.supersafe#supersafe_2.10.4;1.1.0!supersafe_2.10.4.jar(src):
(0ms)
[warn] ==== local: tried
[warn]
/home/user/.ivy2/local/com.artima.supersafe/supersafe_2.10.4/1.1.0/srcs/supersafe_2.10.4-sources.jar
[warn] ==== activator-local: tried [warn] /Development/Activator/activator-dist-1.3.10/repository/com.artima.supersafe/supersafe_2.1...
(show balloon)
What am I supposed to do?
Edit: What else I tried and did not work:
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"
[warn] Multiple dependencies with the same organization/name but
different versions. To avoid conflict, pick one version: [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_2.11" % "1.0.5"
)
// ScalaTest
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test"
Error:Error while importing SBT project:...[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" % "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")
)
[warn] Multiple dependencies with the same organization/name but
different versions. To avoid conflict, pick one version: [warn] *
org.scala-lang.modules:scala-xml_2.11:(1.0.5, 1.0.4)
My build.sbt
name := "MyProject"
version := "0.1.0"
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.scalactic" %% "scalactic" % "3.0.0"
//libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test"
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.0" % "test"
exclude("org.scala-lang", "scala-reflect")
exclude("org.scala-lang.modules", "scala-xml_2.11")
)
The way to exclude specific transitive dependency is this:
Run sbt evicted to figure out which of the project dependencies is pulling in outdated library, let's assume the problematic library is: com.typesafe.slick.
Add the following exclude (the parentheses are important):
("com.typesafe" %% "slick" % "3.1.1").exclude("org.scala-lang.modules", "scala-xml_2.11")
Add this normally as you would be listing dependencies.
This will prevent sbt from including any version of scala-xml that was coming in as a transitive dependency of Slick.
Don't substitute; you need both scalaVersion and libraryDependencies.
Though use
scalaVersion := "2.11.8"
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang.modules" %% "scala-xml" % "1.0.5"
)
to avoid bugs when you eventually change scalaVersion.
By removing scalaVersion you get default scalaVersion := "2.10.4" (with your version/settings of SBT, at least) but your libraryDependencies still require 2.11.
I'm using Play! 2 framework using SBT for dependencies.
I want to retrieve 2.1.0-BUILD-SNAPSHOT version for Spring Data Neo4j
My ApplicationBuild.scala (used by SBT) is the following:
import sbt._
import Keys._
import play.Project._
object ApplicationBuild extends Build {
val appName = "webapp"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
jdbc,
anorm,
"org.springframework" % "spring-aop" % "3.2.0.RELEASE",
"org.springframework" % "spring-aspects" % "3.2.0.RELEASE",
"org.springframework" % "spring-beans" % "3.2.0.RELEASE",
"org.springframework.data" % "spring-data-commons-core" % "1.4.0.RELEASE",
"org.springframework" % "spring-expression" % "3.2.0.RELEASE",
"org.springframework" % "spring-jdbc" % "3.2.0.RELEASE",
"org.springframework" % "spring-orm" % "3.2.0.RELEASE",
"org.springframework" % "spring-test" % "3.2.0.RELEASE",
"org.springframework" % "spring-tx" % "3.2.0.RELEASE",
"org.springframework.data" % "spring-data-neo4j" % "2.1.0.BUILD-SNAPSHOT" excludeAll(
ExclusionRule(organization = "com.sun.jdmk"),
ExclusionRule(organization = "com.sun.jmx"),
ExclusionRule(organization = "javax.jms")
),
"org.neo4j" % "neo4j" % "1.8.1",
"asm" % "asm-all" % "3.1"
)
val main = play.Project(appName, appVersion, appDependencies).settings(
scalaVersion := "2.10.0",
resolvers += "TAMU Release Repository" at "https://maven.library.tamu.edu/content/repositories/releases/",
resolvers += "Spring Maven SNAPSHOT Repository" at "http://repo.springsource.org/libs-snapshot"
)
}
All dependencies are well downloaded except spring-data-neo4j.
It leads to this error:
warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.neo4j#neo4j-cypher-dsl;1.8.RC1: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[error] (*:update) sbt.ResolveException: unresolved dependency: org.neo4j#neo4j-cypher-dsl;1.8.RC1: not found
Is it normal that neo4j-cypher-dsl;1.8.RC1 is not found?
What should I do to retrieve it?
I found a workaround:
Adding:
resolvers += "Neo4j Cypher DSL Repository" at "http://m2.neo4j.org/content/repositories/releases"
will download the missing jar.