Scala - Datastax Cassandra连接失败(在cassandra集群上启用了dse身份验证)

时间:2017-05-17 14:35:27

标签: scala cassandra datastax datastax-enterprise spark-cassandra-connector

我正在使用以下代码来验证数据存储cassandra集群(启用了dse身份验证),但我得到了一个例外。有人可以帮我识别&解决问题,

import com.datastax.driver.core.Cluster

object MySecondScalaWorksheet {
  println("Welcome to the Scala worksheet")       
  def dseConnect(args: Array[String]){
      val cluster = Cluster.builder().addContactPoint("server01.lab.east.com").withCredentials("cassandra", "cassandra").build();
      val session = cluster.connect()
      println(session.getCluster())
    }                                         
}

例外:

java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.datastax.driver.core.Cluster.<clinit>(Cluster.java:64)
at MySecondScalaWorksheet$$anonfun$main$1.apply$mcV$sp(MySecondScalaWork
sheet.scala:6)
at org.scalaide.worksheet.runtime.library.WorksheetSupport$$anonfun$$exe
cute$1.apply$mcV$sp(WorksheetSupport.scala:76)
at org.scalaide.worksheet.runtime.library.WorksheetSupport$.redirected(W
orksheetSupport.scala:65)
at org.scalaide.worksheet.runtime.library.WorksheetSupport$.$execute(Wor
ksheetSupport.scala:75)
at MySecondScalaWorksheet$.main(MySecondScalaWorksheet.scala:3)
at MySecondScalaWorksheet.main(MySecondScalaWorksheet.scala)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)

1 个答案:

答案 0 :(得分:0)

您的构建设置中似乎缺少Guava库。尝试在你的sbt构建文件中添加以下内容。

libraryDependencies += "com.google.guava" % "guava" % "21.0"