ToolBox导入错误

时间:2016-05-20 20:57:18

标签: scala

编译以下玩具类时,我收到以下错误:

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"  

2 个答案:

答案 0 :(得分:3)

以下依赖项修复了该问题:

git status

这是最好的解决方案吗?

答案 1 :(得分:0)

ToolBox类是编译器的一部分,而不是公共反射API。