gpt4 book ai didi

scala - 工具箱导入错误

转载 作者:行者123 更新时间:2023-12-03 10:28:15 28 4
gpt4 key购买 nike

编译以下玩具类时出现以下错误:

package com.example

import scala.tools.reflect.ToolBox
import scala.reflect.runtime.{currentMirror => m}
object Hello {
def main(args: Array[String]): Unit = {
println("Hello, world!")
}
}

[info] Loading project definition from /Users/me/Temp/Bar/project
[info] Set current project to Bar (in build file:/Users/me/Temp/Bar/)
[info] Compiling 1 Scala source to /Users/me/Temp/Bar/target/scala-2.11/classes...
[error] /Users/me/Temp/Bar/src/main/scala/com/example/Hello.scala:3: object tools is not a member of package scala
[error] import scala.tools.reflect.ToolBox
[error] ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed

这是我的 build.sbt文件:
name := """Bar"""

version := "1.0"

scalaVersion := "2.11.8"

// Change this to another test framework if you prefer
libraryDependencies += "org.scalatest" %% "scalatest" % "2.2.4" % "test"
libraryDependencies += "org.scala-lang" % "scala-reflect" % "2.11.8"

// Uncomment to use Akka
//libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.3.11"

最佳答案

以下依赖项解决了该问题:

libraryDependencies += "org.scala-lang" % "scala-compiler" % "2.11.8"

这是最好的解决方案吗?

关于scala - 工具箱导入错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37355729/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com