我的项目依赖于 scala 日志库,我正在尝试升级我的项目以使用 dotty。为此,我从https://github.com/lampepfl/dotty-example-project克隆了示例 dotty 项目,并对其进行了更新,包括日志库。请在下面找到项目的目录结构:-
[hduser@dotty dotty-example-project]$ tree
.
├── build.sbt
├── project
│ ├── build.properties
│ ├── plugins.sbt
│ └── project
└── src
└── main
└── scala
└── Main.scala
5 directories, 4 files
项目/build.properties:-
sbt.version=1.1.6
项目/plugins.sbt
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.2.2")
构建.sbt
libraryDependencies += ("com.typesafe.scala-logging" %% "scala-logging" % "3.7.2").withDottyCompat(scalaVersion.value)
libraryDependencies += ("ch.qos.logback" % "logback-classic" % "1.1.2").withDottyCompat(scalaVersion.value)
lazy val root = project
.in(file("."))
.settings(
name := "dotty-example-project",
description := "Example sbt project that compiles using Dotty",
version := "0.1.0",
scalaVersion := "0.9.0-RC1"
)
src/main/scala/Main.scala
import com.typesafe.scalalogging.LazyLogging
object Main extends LazyLogging{
def main(args : Array[String]) : Unit = {
logger.debug("Hello Dotty")
}
}
上面的scala代码编译得很好
sbt 干净编译
但是 sbt 运行失败并出现以下错误:-
[info] Running Main
[error] (run-main-0) java.lang.NoSuchMethodError: com.typesafe.scalalogging.Logger.debug(Ljava/lang/String;)V
[error] java.lang.NoSuchMethodError: com.typesafe.scalalogging.Logger.debug(Ljava/lang/String;)V
[error] at Main$.main(Main.scala:6)
[error] at Main.main(Main.scala)
[error] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] at java.lang.reflect.Method.invoke(Method.java:498)
[error] at sbt.Run.invokeMain(Run.scala:93)
[error] at sbt.Run.run0(Run.scala:87)
[error] at sbt.Run.execute$1(Run.scala:65)
[error] at sbt.Run.$anonfun$run$4(Run.scala:77)
[error] at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error] at sbt.util.InterfaceUtil$$anon$1.get(InterfaceUtil.scala:10)
[error] at sbt.TrapExit$App.run(TrapExit.scala:252)
[error] at java.lang.Thread.run(Thread.java:748)
[error] java.lang.RuntimeException: Nonzero exit code: 1
[error] at sbt.Run$.executeTrapExit(Run.scala:124)
[error] at sbt.Run.run(Run.scala:77)
[error] at sbt.Defaults$.$anonfun$bgRunTask$5(Defaults.scala:1185)
[error] at sbt.Defaults$.$anonfun$bgRunTask$5$adapted(Defaults.scala:1180)
[error] at sbt.internal.BackgroundThreadPool.$anonfun$run$1(DefaultBackgroundJobService.scala:366)
[error] at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error] at scala.util.Try$.apply(Try.scala:209)
[error] at sbt.internal.BackgroundThreadPool$BackgroundRunnable.run(DefaultBackgroundJobService.scala:289)
[error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] at java.lang.Thread.run(Thread.java:748)
[error] (Compile / run) Nonzero exit code: 1
[error] Total time: 1 s, completed Sep 1, 2018 6:02:01 AM
正如这里所建议的,这可能是因为宏。
请建议,因为我的周末项目依赖于登录,我想将其升级为 dotty。