我的项目依赖于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
project / build.properties:-
sbt.version=1.1.6
project / plugins.sbt
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.2.2")
build.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
如建议here,可能是因为宏。
请提出建议,因为我的周末项目对loggin有依赖性,所以我想将其升级为dotty。
答案 0 :(得分:1)
目前,您唯一可以做的就是找到另一个不需要依赖调用它的宏的日志记录依赖项(或者检查scala-logging的源代码以查看是否存在另一种调用它的方法)不需要宏)