3

我有以下 SBT 文件,我正在使用 Apache GraphFrame 编译 Scala 代码并读取 CSV 文件。

name := "Simple"

version := "1.0"

scalaVersion := "2.10.5"

libraryDependencies ++= Seq(

"org.apache.spark" %% "spark-core" % "1.6.1",

"graphframes" % "graphframes" % "0.2.0-spark1.6-s_2.10",

"org.apache.spark" %% "spark-sql" % "1.0.0",

"com.databricks" % "spark-csv" % "1.0.3"
)

这是我在 Scala 中的代码

import org.graphframes._
import org.apache.spark.sql.DataFrame
    val nodesList = sqlContext.read.format("com.databricks.spark.csv").option("header", "true").option("inferSchema", "true").load("/Users/Desktop/GraphFrame/NodesList.csv")
    val edgesList= sqlContext.read.format("com.databricks.spark.csv").option("header", "true").option("inferSchema", "true").load("/Users/Desktop/GraphFrame/EdgesList.csv")
    val v=nodesList.toDF("id", "name")
    val e=edgesList.toDF("src", "dst", "dist")
    val g = GraphFrame(v, e)

当我尝试使用 SBT 制作 Jar 文件时,在编译过程中出现以下错误

[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: graphframes#graphframes;0.2.0-spark1.6-s_2.10: not found
[error] Total time: 
4

3 回答 3

6

GraphFrames 还没有在 Maven 中央存储库中。

你可以:

  1. 在Spark Packages页面上下载工件并安装到本地存储库中
  2. Spark Packages 存储库添加到您的 SBT 中build.sbt

build.sbt 中的代码:

resolvers += Resolver.url("SparkPackages", url("https://dl.bintray.com/spark-packages/maven/"))
于 2016-12-12T14:09:43.600 回答
6

出于某种原因,Gawęda 的回答中提到的 Resolver.url 对我不起作用,以下工作:

resolvers += "SparkPackages" at "https://dl.bintray.com/spark-packages/maven"

libraryDependencies += "graphframes" % "graphframes" % "0.7.0-spark2.4-s_2.11"

于 2019-03-14T11:48:07.900 回答
3

我设法使用sbt-spark-package让它工作

project/plugins.sbt中,我补充说:

resolvers += "bintray-spark-packages" at "https://dl.bintray.com/spark-packages/maven/"

addSbtPlugin("org.spark-packages" % "sbt-spark-package" % "0.2.5")

然后,在build.sbt我添加:

spDependencies += "graphframes/graphframes:0.5.0-spark2.1-s_2.11"

它奏效了。

希望能帮助到你。

于 2017-06-15T09:23:27.490 回答