我正在使用SBT编译Scala程序,但它为“导入scala.io.Source”、“导入java.io”提供了以下错误
sbt.ResolveException: unresolved dependency: org.scala#scala.io.Source_2.11;latest.integration: not found
[error] unresolved dependency: org.java#java.io_2.11;latest.integration: not found我的SBT格式如下:
name := "Simple Project"
version := "1.0"
scalaVersion := "2.11.7"
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-graphx" % "2.0.1",
"org.scala" %% "scala.io.Source" % "latest.integration",
"org.java" %% "java.io" % "latest.integration"
)任何人都可以帮助我在SBT中指定“导入scala.io.Source”、“导入java.io”。
发布于 2016-11-10 12:10:20
需要区分库依赖项和包导入:库依赖项是通过构建系统来管理的(比如sbt或maven或grails,.)并建立完整的库(如日志API、HTTP实现、.)可用于正在构建的系统。
在程序级别,imports用于将库的特定部分纳入正在开发的代码的范围。
考虑到这个build.sbt
name := "examplebuild"
version := "0.0.1"
scalaVersion := "2.11.7"
libraryDependencies ++= Seq(
"com.typesafe" % "config" % "1.2.1",
"org.scalaj" % "scalaj-http_2.11" % "2.3.0"
)我们可以开发一个scala程序,它可以使用typesafe中的配置库和scalaj中的http库。
Sample.scala
package com.example
import scala.io.Source // from the Scala standard library
import java.io._ // import all io package from the standard java library
import com.typesafe.ConfigFactory // from the typesafe config library
import scalaj.http._ // import all members of the scalaj.http package
class Sample {
// code here
}https://stackoverflow.com/questions/40526231
复制相似问题