为什么 Scala 多平台构建失败并显示“顶级定义 X 在 ... 中定义”?

问题描述 投票:0回答:1

我的多平台构建失败并出现错误,这表明 JVM 和 JS 依赖项都在类路径中。怎么会这样?

[error]    |Toplevel definition EnableReflectiveInstantiation is defined in
[error]    |  /home/runner/.cache/coursier/v1/https/repo1.maven.org/maven2/org/portable-scala/portable-scala-reflect_sjs1_2.13/1.1.2/portable-scala-reflect_sjs1_2.13-1.1.2.jar(org/portablescala/reflect/annotation/package.class)
[error]    |and also in
[error]    |  /home/runner/.cache/coursier/v1/https/repo1.maven.org/maven2/org/portable-scala/portable-scala-reflect_2.13/1.1.2/portable-scala-reflect_2.13-1.1.2.jar(org/portablescala/reflect/annotation/EnableReflectiveInstantiation.class)
[error]    |One of these files should be removed from the classpath.
scala sbt scala.js
1个回答
0
投票

如果 sbt 中的一个或多个依赖项使用非平台感知运算符

%%
而不是平台感知
%%%
,就会发生此类错误。因此,将 JVM 依赖项添加到您的 JS 构建中

© www.soinside.com 2019 - 2024. All rights reserved.