Warm tip: This article is reproduced from serverfault.com, please click

scala-ScalaJs + ZIO:程序适用于sbt 1.2.8,但不适用于> = 1.3

(scala - ScalaJs + ZIO: Program works with sbt 1.2.8 but not >= 1.3)

发布于 2020-11-29 18:40:51

我正在使用https://github.com/wongelz/zio-scalajs-solarsystem上的示例应用程序使用zio尝试scala.js

将sbt版本从1.2.8更新到1.3.13或1.4.4时,出现以下错误:

[error] Referring to non-existent method java.time.LocalTime$.NANOS_PER_SECOND()long
[error]   called from private java.time.LocalDateTime.plusWithOverflow(java.time.LocalDate,long,long,long,long,int)java.time.LocalDateTime
[error]   called from java.time.LocalDateTime.plusNanos(long)java.time.LocalDateTime
[error]   called from java.time.LocalDateTime.plus(long,java.time.temporal.TemporalUnit)java.time.LocalDateTime
[error]   called from java.time.LocalDateTime.plus(long,java.time.temporal.TemporalUnit)java.time.temporal.Temporal
[error]   called from java.time.temporal.ChronoUnit.addTo(java.time.temporal.Temporal,long)java.time.temporal.Temporal
[error]   called from java.time.OffsetDateTime.plus(long,java.time.temporal.TemporalUnit)java.time.OffsetDateTime
[error]   called from java.time.OffsetDateTime.plus(long,java.time.temporal.TemporalUnit)java.time.temporal.Temporal
[error]   called from java.time.Duration.addTo(java.time.temporal.Temporal)java.time.temporal.Temporal
[error]   called from java.time.OffsetDateTime.plus(java.time.temporal.TemporalAmount)java.time.OffsetDateTime
[error]   called from private zio.Schedule$.$anonfun$fixed$2(scala.Option,java.time.OffsetDateTime,long,java.time.Duration,long,scala.runtime.LazyRef)zio.Schedule$Decision
[error]   called from private zio.Schedule$.$anonfun$fixed$1(scala.Option,long,java.time.Duration,long,scala.runtime.LazyRef,java.time.OffsetDateTime,java.lang.Object)zio.ZIO
[error]   called from private zio.Schedule$.loop$23(scala.Option,long,long,java.time.Duration,scala.runtime.LazyRef)scala.Function2
[error]   called from zio.Schedule$.fixed(java.time.Duration)zio.Schedule
[error]   called from private SolarSystemExample$.$anonfun$run$1(SolarSystemExample$SolarSystem)zio.ZIO
[error]   called from SolarSystemExample$.run(scala.collection.immutable.List)zio.ZIO
[error]   called from private zio.App.$anonfun$main$1([java.lang.String)zio.ZIO
[error]   called from zio.App.main([java.lang.String)void
[error]   called from SolarSystemExample$.main([java.lang.String)void
[error]   called from static SolarSystemExample.main([java.lang.String)void
[error]   called from core module module initializers
[error] involving instantiated classes:
[error]   java.time.LocalDateTime
[error]   java.time.temporal.ChronoUnit
[error]   java.time.OffsetDateTime
[error]   java.time.Duration
[error]   zio.Schedule$
[error]   SolarSystemExample$

为什么会发生此错误?我应该在哪里举报呢?

Questioner
Dominik Dorn
Viewed
0
Dominik Dorn 2020-12-13 20:12:59

要回答我自己的问题(对于遇到同样问题的任何人):

确保你scalajs-java-time的类路径中没有(1.0.0)作为依赖项。 它是一个不完整的库,如果你选择它,则scala-java-time你将收到问题中张贴的错误。

发生此错误的原因是,至少在我的系统上,类路径的顺序从sbt 1.2.8更改sbt 1.3.x,导致选择了scalajs-java-time库,然后scala-java-time导致

Referring to non-existent method java.time.LocalTime$.NANOS_PER_SECOND()long

错误