如何在SBT中编写"import scala.io.Source","import java.io"库

Yas*_*sir 3 scala sbt apache-spark

我正在使用SBT编译Scala程序,但它为"import scala.io.Source","import 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
Run Code Online (Sandbox Code Playgroud)

我的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"
)
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮助我如何在SBT中指定"import scala.io.Source","import java.io".

maa*_*asg 5

需要区分库依赖项和包导入:库依赖项通过构建系统(如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"
)
Run Code Online (Sandbox Code Playgroud)

我们可以开发一个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
}
Run Code Online (Sandbox Code Playgroud)