使用janusgraph和gremlin scala构建火花sbt

时间:2018-01-22 14:39:44

标签: scala apache-spark gremlin janusgraph

我试图使用gremlin scala为janusgraph设置一个IntelliJ版本的spark,但是我遇到了错误。

我的build.sbt文件是:

version := "1.0"

scalaVersion := "2.11.11"

libraryDependencies += "com.michaelpollmeier" % "gremlin-scala" % "2.3.0"
libraryDependencies += "org.apache.spark" %% "spark-core" % "2.2.1"
// https://mvnrepository.com/artifact/org.apache.spark/spark-sql
libraryDependencies += "org.apache.spark" %% "spark-sql" % "2.2.1"
// https://mvnrepository.com/artifact/org.apache.spark/spark-mllib
libraryDependencies += "org.apache.spark" %% "spark-mllib" % "2.2.1"
// https://mvnrepository.com/artifact/org.apache.spark/spark-hive
libraryDependencies += "org.apache.spark" %% "spark-hive" % "2.2.1"
// https://mvnrepository.com/artifact/org.janusgraph/janusgraph-core
libraryDependencies += "org.janusgraph" % "janusgraph-core" % "0.2.0"

libraryDependencies ++= Seq(
  "ch.qos.logback" % "logback-classic" % "1.2.3" % Test,
  "org.scalatest" %% "scalatest" % "3.0.3" % Test
)

resolvers ++= Seq(
  Resolver.mavenLocal,
  "Sonatype OSS" at "https://oss.sonatype.org/content/repositories/public"
) 

但是当我尝试编译使用gremlin scala库或io.Source库的代码时,我遇到了错误。有人可以共享他们的构建文件或告诉我应该修改它来修复它。 提前致谢。

所以,我试图编译这段代码:

import gremlin.scala._
import org.apache.commons.configuration.BaseConfiguration
import org.janusgraph.core.JanusGraphFactory


class Test1() {
  val conf = new BaseConfiguration()
  conf.setProperty("storage.backend", "inmemory")
  val gr = JanusGraphFactory.open(conf)
  val graph = gr.asScala()
  graph.close

}

object Test{
  def main(args: Array[String]) {
    val t = new Test1()
    println("in Main")
  }
}

我得到的错误是:

错误:(1,8)未找到:对象gremlin 导入gremlin.scala ._

错误:(10,18)值asScala不是org.janusgraph.core.JanusGraph的成员   val graph = gr.asScala()

1 个答案:

答案 0 :(得分:2)

如果您转到Gremlin-Scala GitHub page,您会看到当前版本为" 3.3.1.1"那个

  

通常,您只需要在"com.michaelpollmeier" %% "gremlin-scala" % "SOME_VERSION"上添加一个依赖项,并为您的build.sbt添加一个您选择的图形数据库(本自述文件假定为tinkergraph)。最新版本显示在maven徽章中自述文件的顶部。

当主要版本的APi发生变化时,这并不奇怪 图书馆是不同的。如果我将您的第一个依赖项更改为

//libraryDependencies += "com.michaelpollmeier" % "gremlin-scala" % "2.3.0" //old!
libraryDependencies += "com.michaelpollmeier" %% "gremlin-scala" % "3.3.1.1"

然后你的示例代码为我编译。