在我的项目中,我遇到了 cats 库的版本后缀冲突错误。我运行了 sbt evicted,但我无法完全理解如何解释它来解决此错误。以下是 evicted 的输出:
* org.scala-lang:scala-library:2.13.12 is selected over {2.13.10, 2.13.8, 2.13.5}
[warn] +- org.scala-lang:scala3-library_3:3.4.0 (depends on 2.13.12)
[warn] +- org.typelevel:cats-kernel_2.13:2.9.0 (depends on 2.13.10)
[warn] +- org.typelevel:cats-core_2.13:2.9.0 (depends on 2.13.10)
[warn] +- org.scala-lang.modules:scala-java8-compat_2.13:1.0.0 (depends on 2.13.5)
[warn] +- com.typesafe.akka:akka-stream_2.13:2.6.21 (depends on 2.13.8)
[warn] +- com.typesafe.akka:akka-slf4j_2.13:2.6.21 (depends on 2.13.8)
[warn] +- com.typesafe.akka:akka-serialization-jackson_2.13:2.6.21 (depends on 2.13.8)
[warn] +- com.typesafe.akka:akka-parsing_2.13:10.2.10 (depends on 2.13.8)
[warn] +- com.typesafe.akka:akka-http-core_2.13:10.2.10 (depends on 2.13.8)
[warn] +- com.typesafe.akka:akka-actor_2.13:2.6.21 (depends on 2.13.8)
[warn] +- com.typesafe.akka:akka-actor-typed_2.13:2.6.21 (depends on 2.13.8)
[warn] +- com.typesafe:ssl-config-core_2.13:0.6.1 (depends on 2.13.8)
[warn] +- com.fasterxml.jackson.module:jackson-module-scala_2.13:2.14.3 (depends on 2.13.10)
[warn] To force scalaVersion, add the following:
[warn] scalaModuleInfo ~= (_.map(_.withOverrideScalaVersion(true)))
[warn] Found version conflict(s) in library dependencies; some are suspected to be binary incompatible:
[warn] * com.fasterxml.jackson.module:jackson-module-scala_2.13:2.14.3 is selected over 2.11.4
[warn] +- com.openelectrons:ocpp-gateway-server_3:1.0-SNAPSHOT (depends on 2.14.3)
[warn] +- com.typesafe.akka:akka-serialization-jackson_2.13:2.6.21 (depends on 2.11.4)
[warn] * com.typesafe:ssl-config-core_2.13:0.6.1 is selected over 0.4.3
[warn] +- com.openelectrons:ocpp-gateway-server_3:1.0-SNAPSHOT (depends on 0.6.1)
[warn] +- com.typesafe.akka:akka-stream_2.13:2.6.21 (depends on 0.4.3)
[info] Here are other dependency conflicts that were resolved:
[info] * com.typesafe:config:1.4.3 is selected over {1.4.2}
[info] +- com.typesafe.play:play-configuration_3:2.9.6 (depends on 1.4.3)
[info] +- com.typesafe.akka:akka-actor_2.13:2.6.21 (depends on 1.4.2)
[info] +- com.typesafe:ssl-config-core_2.13:0.6.1 (depends on 1.4.2)
[info] * com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.3 is selected over 2.11.4
[info] +- org.playframework:play-json_3:3.0.4 (depends on 2.14.3)
[info] +- com.typesafe.play:play_3:2.9.6 (depends on 2.14.3)
[info] +- com.typesafe.play:play-json_3:2.10.6 (depends on 2.14.3)
[info] +- com.typesafe.akka:akka-serialization-jackson_2.13:2.6.21 (depends on 2.11.4)
[info] * org.reactivestreams:reactive-streams:1.0.4 is selected over {1.0.3}
[info] +- com.typesafe.play:play-streams_3:2.9.6 (depends on 1.0.4)
[info] +- com.hivemq:hivemq-mqtt-client:1.3.3 (depends on 1.0.4)
[info] +- io.reactivex.rxjava2:rxjava:2.2.21 (depends on 1.0.3)
[info] +- io.monix:monix-execution_3:3.4.0 (depends on 1.0.3)
[info] +- com.typesafe.akka:akka-stream_2.13:2.6.21 (depends on 1.0.3)
[info] * org.postgresql:postgresql:42.6.0 is selected over 42.3.1
[info] +- com.openelectrons:ocpp-gateway-server_3:1.0-SNAPSHOT (depends on 42.6.0)
[info] +- org.tpolecat:doobie-postgres_3:1.0.0-RC4 (depends on 42.6.0)
[info] +- org.postgresql:postgresql:42.3.1 (depends on 42.3.1)
[info] * com.h2database:h2:1.4.200 is selected over 1.4.199
[info] +- com.openelectrons:ocpp-gateway-server_3:1.0-SNAPSHOT (depends on 1.4.200)
[info] +- org.tpolecat:doobie-h2_3:1.0.0-RC4 (depends on 1.4.200)
[info] +- com.h2database:h2:1.4.199 (depends on 1.4.199)
[info] * ch.qos.logback:logback-classic:1.5.12 is selected over 1.2.6
[info] +- com.openelectrons:ocpp-gateway-server_3:1.0-SNAPSHOT (depends on 1.5.12)
[info] +- com.typesafe.play:play-logback_3:2.9.6 (depends on 1.5.12)
[info] +- ch.qos.logback:logback-classic:1.2.6 (depends on 1.2.6)
[info] * org.checkerframework:checker-qual:3.37.0 is selected over {3.31.0}
[info] +- org.postgresql:postgresql:42.3.1 (depends on 3.37.0)
[info] +- org.postgresql:postgresql:42.6.0 (depends on 3.31.0)
[info] * co.fs2:fs2-core_3:3.9.1 is selected over {3.7.0}
[info] +- com.openelectrons:ocpp-gateway-server_3:1.0-SNAPSHOT (depends on 3.9.1)
[info] +- org.tpolecat:doobie-free_3:1.0.0-RC4 (depends on 3.7.0)
[info] +- co.fs2:fs2-io_3:3.7.0 (depends on 3.7.0)
[info] * com.fasterxml.jackson.core:jackson-annotations:2.14.3 is selected over {2.11.4}
[info] +- org.playframework:play-json_3:3.0.4 (depends on 2.14.3)
[info] +- com.fasterxml.jackson.module:jackson-module-scala_2.13:2.14.3 (depends on 2.14.3)
[info] +- com.typesafe.play:play_3:2.9.6 (depends on 2.14.3)
[info] +- com.typesafe.play:play-json_3:2.10.6 (depends on 2.14.3)
[info] +- com.typesafe.akka:akka-serialization-jackson_2.13:2.6.21 (depends on 2.11.4)
[info] * com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.14.3 is selected over 2.11.4
[info] +- com.typesafe.play:play_3:2.9.6 (depends on 2.14.3)
[info] +- com.typesafe.akka:akka-serialization-jackson_2.13:2.6.21 (depends on 2.11.4)
[info] * com.fasterxml.jackson.core:jackson-core:2.14.3 is selected over {2.11.4}
[info] +- org.playframework:play-json_3:3.0.4 (depends on 2.14.3)
[info] +- com.fasterxml.jackson.module:jackson-module-scala_2.13:2.14.3 (depends on 2.14.3)
[info] +- com.typesafe.play:play_3:2.9.6 (depends on 2.14.3)
[info] +- com.typesafe.play:play-json_3:2.10.6 (depends on 2.14.3)
[info] +- com.typesafe.akka:akka-serialization-jackson_2.13:2.6.21 (depends on 2.11.4)
[info] * org.typelevel:cats-core_3:2.12.0 is selected over {2.10.0, 2.9.0}
[info] +- com.openelectrons:ocpp-gateway-server_3:1.0-SNAPSHOT (depends on 2.12.0)
[info] +- org.typelevel:cats-free_3:2.9.0 (depends on 2.9.0)
[info] +- org.typelevel:cats-effect-kernel_3:3.5.7 (depends on 2.9.0)
[info] +- org.tpolecat:doobie-free_3:1.0.0-RC4 (depends on 2.9.0)
[info] +- com.comcast:ip4s-core_3:3.3.0 (depends on 2.9.0)
[info] +- co.fs2:fs2-core_3:3.9.1 (depends on 2.10.0)
[info] * org.typelevel:cats-effect_3:3.5.7 is selected over {3.5.1, 3.4.8, 3.5.0}
[info] +- com.openelectrons:ocpp-gateway-server_3:1.0-SNAPSHOT (depends on 3.5.7)
[info] +- org.tpolecat:doobie-free_3:1.0.0-RC4 (depends on 3.5.0)
[info] +- com.comcast:ip4s-core_3:3.3.0 (depends on 3.4.8)
[info] +- co.fs2:fs2-core_3:3.9.1 (depends on 3.5.1)
[info] * com.fasterxml.jackson.module:jackson-module-parameter-names:2.14.3 is selected over 2.11.4
[info] +- com.typesafe.play:play_3:2.9.6 (depends on 2.14.3)
[info] +- com.typesafe.akka:akka-serialization-jackson_2.13:2.6.21 (depends on 2.11.4)
[info] * com.fasterxml.jackson.core:jackson-databind:2.14.3 is selected over {2.11.4}
[info] +- org.playframework:play-json_3:3.0.4 (depends on 2.14.3)
[info] +- com.fasterxml.jackson.module:jackson-module-scala_2.13:2.14.3 (depends on 2.14.3)
[info] +- com.typesafe.play:play_3:2.9.6 (depends on 2.14.3)
[info] +- com.typesafe.play:play-json_3:2.10.6 (depends on 2.14.3)
[info] +- com.typesafe.akka:akka-serialization-jackson_2.13:2.6.21 (depends on 2.11.4)
[info] * com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.14.3 is selected over 2.11.4
[info] +- org.playframework:play-json_3:3.0.4 (depends on 2.14.3)
[info] +- com.typesafe.play:play_3:2.9.6 (depends on 2.14.3)
[info] +- com.typesafe.play:play-json_3:2.10.6 (depends on 2.14.3)
[info] +- com.typesafe.akka:akka-serialization-jackson_2.13:2.6.21 (depends on 2.11.4)
[info] * org.scala-lang:scala3-library_3:3.4.0 is selected over {3.3.0, 3.2.2, 3.3.4, 3.3.3, 3.0.0, 3.2.1, 3.1.3}
[info] +- com.openelectrons:ocpp-gateway-server_3:1.0-SNAPSHOT (depends on 3.4.0)
[info] +- com.openelectrons:ocpiv22-api_3:0.0.1-SNAPSHOT (depends on 3.4.0)
[info] +- com.openelectrons:ocpp-messages_3:0.0.1-SNAPSHOT (depends on 3.4.0)
[info] +- com.openelectrons:ocpiv22-messages_3:0.0.1-SNAPSHOT (depends on 3.4.0)
[info] +- com.openelectrons:ocpp-j-api_3:0.0.1-SNAPSHOT (depends on 3.4.0)
[info] +- org.typelevel:literally_3:1.1.0 (depends on 3.1.3)
[info] +- org.typelevel:cats-kernel_3:2.12.0 (depends on 3.3.3)
[info] +- org.typelevel:cats-free_3:2.9.0 (depends on 3.2.1)
[info] +- org.typelevel:cats-effect_3:3.5.7 (depends on 3.2.2)
[info] +- org.typelevel:cats-effect-std_3:3.5.7 (depends on 3.2.2)
[info] +- org.typelevel:cats-effect-kernel_3:3.5.7 (depends on 3.2.2)
[info] +- org.typelevel:cats-core_3:2.12.0 (depends on 3.3.3)
[info] +- org.tpolecat:typename_3:1.1.0 (depends on 3.2.2)
[info] +- org.tpolecat:doobie-postgres_3:1.0.0-RC4 (depends on 3.3.0)
[info] +- org.tpolecat:doobie-hikari_3:1.0.0-RC4 (depends on 3.3.0)
[info] +- org.tpolecat:doobie-h2_3:1.0.0-RC4 (depends on 3.3.0)
[info] +- org.tpolecat:doobie-free_3:1.0.0-RC4 (depends on 3.3.0)
[info] +- org.tpolecat:doobie-core_3:1.0.0-RC4 (depends on 3.3.0)
[info] +- org.scodec:scodec-bits_3:1.1.37 (depends on 3.2.2)
[info] +- org.scala-lang.modules:scala-xml_3:2.2.0 (depends on 3.3.0)
[info] +- org.scala-lang.modules:scala-parser-combinators_3:2.3.0 (depends on 3.2.2)
[info] +- org.playframework:play-json_3:3.0.4 (depends on 3.3.3)
[info] +- org.playframework:play-functional_3:3.0.4 (depends on 3.3.3)
[info] +- io.monix:monix-execution_3:3.4.0 (depends on 3.0.0)
[info] +- io.monix:implicitbox_3:0.3.4 (depends on 3.0.0)
[info] +- com.typesafe.play:twirl-api_3:1.6.8 (depends on 3.3.3)
[info] +- com.typesafe.play:play_3:2.9.6 (depends on 3.3.4)
[info] +- com.typesafe.play:play-streams_3:2.9.6 (depends on 3.3.4)
[info] +- com.typesafe.play:play-server_3:2.9.6 (depends on 3.3.4)
[info] +- com.typesafe.play:play-logback_3:2.9.6 (depends on 3.3.4)
[info] +- com.typesafe.play:play-json_3:2.10.6 (depends on 3.3.3)
[info] +- com.typesafe.play:play-json-joda_3:2.10.6 (depends on 3.3.3)
[info] +- com.typesafe.play:play-functional_3:2.10.6 (depends on 3.3.3)
[info] +- com.typesafe.play:play-filters-helpers_3:2.9.6 (depends on 3.3.4)
[info] +- com.typesafe.play:play-configuration_3:2.9.6 (depends on 3.3.4)
[info] +- com.typesafe.play:play-akka-http-server_3:2.9.6 (depends on 3.3.4)
[info] +- com.comcast:ip4s-core_3:3.3.0 (depends on 3.2.2)
[info] +- co.fs2:fs2-io_3:3.7.0 (depends on 3.2.2)
[info] +- co.fs2:fs2-core_3:3.9.1 (depends on 3.3.0)
这是我遇到的错误:
[error] java.lang.RuntimeException: Conflicting cross-version suffixes in: org.typelevel:cats-kernel, org.typelevel:cats-core
[error] at scala.sys.package$.error(package.scala:30)
[error] at sbt.librarymanagement.ConflictWarning$.processCrossVersioned(ConflictWarning.scala:39)
[error] at sbt.librarymanagement.ConflictWarning$.apply(ConflictWarning.scala:19)
[error] at sbt.Classpaths$.$anonfun$ivyBaseSettings$71(Defaults.scala:3403)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error] at sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error] at sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error] at sbt.Execute.work(Execute.scala:292)
[error] at sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[error] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
[error] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[error] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
[error] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
[error] at java.base/java.lang.Thread.run(Thread.java:1583)
[error] (update) Conflicting cross-version suffixes in: org.typelevel:cats-kernel, org.typelevel:cats-core
这些是我的依赖项:
libraryDependencies ++= Seq(
// Add explicit Cats dependencies
"org.typelevel" %% "cats-core" % catsVersion,
"org.typelevel" %% "cats-kernel" % catsVersion,
"org.typelevel" %% "cats-effect" % "3.5.7",
// Database libraries
"org.postgresql" % "postgresql" % "42.3.1",
"com.h2database" % "h2" % "1.4.199",
"org.tpolecat" %% "doobie-core" % doobieVersion exclude ("org.typelevel", "cats-core"),
"org.tpolecat" %% "doobie-postgres" % doobieVersion,
"org.tpolecat" %% "doobie-h2" % doobieVersion,
"org.tpolecat" %% "doobie-hikari" % doobieVersion,
"ch.qos.logback" % "logback-classic" % "1.2.6",
"org.playframework" %% "play-json" % "3.0.4",
"com.typesafe.play" %% "play-json-joda" % "2.10.6",
// For caching and distributed caching
//"com.github.cb372" %% "scalacache-core" % "0.28.0",
//"com.github.cb372" %% "scalacache-guava" % "0.28.0",
// For application Metrics
"io.dropwizard.metrics" % "metrics-core" % dropWizardMetricsVersion,
"io.dropwizard.metrics" % "metrics-jvm" % dropWizardMetricsVersion,
// Threading & Streaming libraries (https://monix.io/docs/current/intro/usage.html)
"io.monix" %% "monix-execution" % "3.4.0",
"co.fs2" %% "fs2-core" % "3.9.1",
// MQTT client
"com.hivemq" % "hivemq-mqtt-client" % "1.3.3",
// OCPP & OCPI Core libraries
"com.openelectrons" %% "ocpp-j-api" % "0.0.1-SNAPSHOT",
"com.openelectrons" %% "ocpp-messages" % "0.0.1-SNAPSHOT",
"com.openelectrons" %% "ocpiv22-messages" % "0.0.1-SNAPSHOT",
"com.openelectrons" %% "ocpiv22-api" % "0.0.1-SNAPSHOT",
// Test libraries
"org.scalatestplus.play" %% "scalatestplus-play" % "7.0.1" % Test exclude ("org.slf4j", "slf4j-simple"),
"org.specs2" %% "specs2-core" % "4.20.0" % Test,
"org.scalacheck" %% "scalacheck" % "1.18.1" % Test,
"org.testcontainers" % "hivemq" % "1.19.7" % Test,
"com.dimafeng" %% "testcontainers-scala-scalatest" % "0.41.3" % Test,
"com.dimafeng" %% "testcontainers-scala-postgresql" % "0.41.0" % Test
// https://github.com/DanielaSfregola/random-data-generator
//"com.danielasfregola" %% "random-data-generator" % "2.9" % Test
)
编辑:Akka HTTP SBT 模块的重复已通过 ProjectRrf 中冲突的跨版本后缀解决
除了 Mateusz 所解释的内容之外,错误消息还表明您在 Scala 2 和 Scala 3“变体”中都拉了一些依赖项(
cats-kernel
和),即和被拉(其中后缀是 Scala 版本)。cats-core
cats-core_2.13
cats-core_3
这是被禁止的。
当传递地拉取多个依赖项和/或使用 SBT
for3Use2.13
/for2.13Use3
选项时(在这种情况下看起来您没有使用它),可能会发生这种情况。例如,也许您明确地拉取了 Cats Scala 3,但您拉取了 Scala 2.13 变体中的依赖项 X(您可以,它与 Scala 3 兼容),而该变体本身又拉取了 Scala 2.13 的 Cats。
在这种情况下,您应该排除两只猫中的一只,最有可能的是 2.13 猫。