【发布时间】:2021-11-08 22:58:33
【问题描述】:
我正在尝试在scala 3 代码中使用discord4j 3.2 和斜杠命令。当我添加斜杠命令的代码时,sbt 在编译时给了我这个错误:
[error] Bad symbolic reference. A signature
[error] refers to Value/T in package org.immutables.value which is not available.
[error] It may be completely missing from the current classpath, or the version on
[error] the classpath might be incompatible with the version used when compiling the signature.
[warn] Caught: java.lang.AssertionError: assertion failed: failure to resolve inner class:
[warn] externalName = org.immutables.value.Value$Immutable,
[warn] outerName = org.immutables.value.Value,
[warn] innerName = Immutable
[warn] owner.fullName = org.immutables.value.Value
[warn] while parsing ~/.cache/coursier/v1/https/oss.sonatype.org/content/repositories/snapshots/com/discord4j/discord-json/1.6.10-SNAPSHOT/discord-json-1.6.10-20210908.025209-4.jar(discord4j/discordjson/json/InteractionApplicationCommandCallbackData.class) while parsing annotations in ~/.cache/coursier/v1/https/oss.sonatype.org/content/repositories/snapshots/com/discord4j/discord-json/1.6.10-SNAPSHOT/discord-json-1.6.10-20210908.025209-4.jar(discord4j/discordjson/json/InteractionApplicationCommandCallbackData.class)
[error] Bad symbolic reference. A signature
使用相同版本的discord4j 但在scala 2 代码中编译创建斜线命令的代码没有问题。
这是我的sbt 文件:
val scala3Version = "3.0.2"
val scala2deps = Seq(
"com.typesafe.akka" %% "akka-actor" % "2.6.0",
"com.typesafe.akka" %% "akka-actor-typed" % "2.6.0",
"com.typesafe.akka" %% "akka-stream" % "2.6.8",
"com.typesafe.akka" %% "akka-http" % "10.2.0",
"org.scalaz" %% "scalaz-core" % "7.2.29",
"io.projectreactor" %% "reactor-scala-extensions" % "0.8.+",
"org.json4s" %% "json4s-jackson" % "3.+",
"com.lihaoyi" %% "requests" % "0.2.0",
).map(d ⇒ d.cross(CrossVersion.for3Use2_13))
lazy val root = project
.in(file("."))
.settings(
name := "PUGBot",
version := "0.1.0",
scalacOptions ++= Seq(
"-language:postfixOps",
"-language:implicitConversions",
),
scalaVersion := scala3Version,
resolvers += "d4j-snapshot" at "https://oss.sonatype.org/content/repositories/snapshots",
libraryDependencies ++= Seq(
"com.discord4j" % "discord4j-core" % "3.2.0-RC3",
) ++ scala2deps,
)
我该如何解决这个错误?
【问题讨论】:
-
这类错误通常表明您正在尝试使用旧版本的
sbt编译 Scala 3。确保您使用的是最新版本。