我正在尝试按照一些教程来了解有关 Scala 的更多信息,并且我正在尝试在我的计算机(MacBook Pro M1)的 IntelliJ 中使用它。我使用sdkman安装了sdk。但是,我遇到了一些关于它的错误,并且我不知道如何解决这个问题。
编辑:按照下面的建议,有关我如何安装它的更多信息:
我正在尝试 LinkedIn Learning 上的Scala 简介课程。我安装了 IntelliJ 的社区版本 (Apple Sillicon) 在此处可用,然后使用命令
curl -fL https://github.com/coursier/launchers/raw/master/cs-x86_64-apple-darwin.gz | gzip -d > cs && chmod +x cs && (xattr -d com.apple.quarantine cs || true) && ./cs setup
在此处可用 安装了 Scala。最后,我使用 curl -s "https://get.sdkman.io" | bash
和 source "$HOME/.sdkman/bin/sdkman-init.sh"
安装 SDK,遵循 这里提供的内容。
毕竟,当我进入终端并写入
sbt -version
或者如果我尝试在 IntelliJ 中运行某些内容时,会出现以下错误:
java.lang.ClassCastException: class java.lang.UnsupportedOperationException cannot be cast to class xsbti.FullReload (java.lang.UnsupportedOperationException is in module java.base of loader 'bootstrap'; xsbti.FullReload is in unnamed module of loader 'app')
at sbt.internal.XMainConfiguration.run(XMainConfiguration.java:59)
at sbt.xMain.run(Main.scala:46)
at xsbt.boot.Launch$.$anonfun$run$1(Launch.scala:149)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:176)
at xsbt.boot.Launch$.run(Launch.scala:149)
at xsbt.boot.Launch$.$anonfun$apply$1(Launch.scala:44)
at xsbt.boot.Launch$.launch(Launch.scala:159)
at xsbt.boot.Launch$.apply(Launch.scala:44)
at xsbt.boot.Launch$.apply(Launch.scala:21)
at xsbt.boot.Boot$.runImpl(Boot.scala:78)
at xsbt.boot.Boot$.run(Boot.scala:73)
at xsbt.boot.Boot$.main(Boot.scala:21)
at xsbt.boot.Boot.main(Boot.scala)
[error] [launcher] error during sbt launcher: java.lang.ClassCastException: class java.lang.UnsupportedOperationException cannot be cast to class xsbti.FullReload (java.lang.UnsupportedOperationException is in module java.base of loader 'bootstrap'; xsbti.FullReload is in unnamed module of loader 'app')
我不知道这意味着什么以及如何解决这个问题。有人可以帮我吗?
你应该控制你的java版本。当我将版本降级到 java 11 时问题解决了。
我能够按照存储库中的说明使其正常工作xsbt
在修改 SBT 部分指出,
如果项目定义了project/build.properties,请删除该文件或将sbt.version更改为0.13.0-SNAPSHOT。
就我而言,原因在于 JDK 版本。完成此步骤后即可正常工作。
java -version
/usr/libexec/java_home -V
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
来源:http://lertsirikarn.blogspot.com/2022/05/how-to-fix-sbt-error-error-during-sbt.html
已经在评论中,但将其作为答案发布:
project/build.properties
下指定的sbt版本应与您实际的sbt版本匹配(您可以通过在项目文件夹外运行$ sbt -version
来获取它)。
因此相应地编辑
project/build.properties
:
sbt.version=1.9.3