我正在使用 Scala 3 和 SBT 构建一个 Akka HTTP 应用程序,它一开始运行良好。
但是当我将下面的新依赖项添加到
build.sbt
时,应用程序开始给出错误 modules were resolved with conflicting cross-version suffixes in ProjectRrf
。
添加的新依赖项有:
akka-http-circe
、akka-http-json4s
、json4s-native
、circe-generic
、scala-logging
。
为了使依赖项与 scala3 兼容,我使用
.cross(CrossVersion.for3Use2_13)
包装了其中一些依赖项。
导致此错误的原因可能是什么?
提前致谢!
添加了新的依赖项:
("com.typesafe.scala-logging" %% "scala-logging" % "3.9.3").cross(CrossVersion.for3Use2_13),
("de.heikoseeberger" %% "akka-http-circe" % "1.39.2").cross(CrossVersion.for3Use2_13),
("de.heikoseeberger" %% "akka-http-json4s" % "1.39.2").cross(CrossVersion.for3Use2_13),
("org.json4s" %% "json4s-native" % "4.1.0-M4").cross(CrossVersion.for3Use2_13),
("io.circe" %% "circe-generic" % "0.15.0-M1").cross(CrossVersion.for3Use2_13),
build.sbt:
lazy val akkaHttpVersion = "10.6.3"
lazy val akkaVersion = "2.9.4"
resolvers += "Akka library repository".at("https://repo.akka.io/maven")
fork := true
lazy val root = (project in file(".")).
settings(
inThisBuild(List(
organization := "com.example",
scalaVersion := "3.3.3"
)),
name := "eskimi-bidding-agent",
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-http" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-http-spray-json" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-actor-typed" % akkaVersion,
"com.typesafe.akka" %% "akka-stream" % akkaVersion,
"com.typesafe.akka" %% "akka-pki" % akkaVersion,
("com.typesafe.scala-logging" %% "scala-logging" % "3.9.3").cross(CrossVersion.for3Use2_13),
("de.heikoseeberger" %% "akka-http-circe" % "1.39.2").cross(CrossVersion.for3Use2_13),
("de.heikoseeberger" %% "akka-http-json4s" % "1.39.2").cross(CrossVersion.for3Use2_13),
("org.json4s" %% "json4s-native" % "4.1.0-M4").cross(CrossVersion.for3Use2_13),
("io.circe" %% "circe-generic" % "0.15.0-M1").cross(CrossVersion.for3Use2_13),
"ch.qos.logback" % "logback-classic" % "1.2.11",
"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion % Test,
"com.typesafe.akka" %% "akka-actor-testkit-typed" % akkaVersion % Test,
"org.scalatest" %% "scalatest" % "3.2.12" % Test
)
)
发生错误的原因是您使用不兼容的 Scala 版本后缀(传递性地)拉取了相同的依赖项/工件。
我没有检查你的具体情况,但例如可能是:
akka-http
用于 Scala 3 拉取库 X
用于 Scala 3akka-http-circe
对于 Scala 3 使用 2.13(由于 for3Use2_13
)并为 Scala 2.13拉取库
X
冲突在于 Scala 3 和 2.13 中的库
X
均被拉取。
您可能可以通过排除这两个版本之一来逃脱惩罚。尽管取决于库,但情况可能并不总是如此。