【发布时间】:2017-10-11 20:44:04
【问题描述】:
我正在尝试从 Hbase 文档 http://hbase.apache.org/1.2/book.html#scala 编译和运行 scala 示例 但我收到无法导入 Connection 和 ConnectionFactory 类的编译错误。
我尝试了两个 scala 版本 2.10.6 和 2.11.11,但在这两种情况下都失败了。
简单的 Scala 代码:
import org.apache.hadoop.hbase.HBaseConfiguration
import org.apache.hadoop.hbase.client.Connection
import org.apache.hadoop.hbase.client.ConnectionFactory
object Client {
def main(args: Array[String]): Unit = {
val conf = new HBaseConfiguration()
val connection = ConnectionFactory.createConnection(conf)
val admin = connection.getAdmin()
// list the tables
val listtables=admin.listTables()
listtables.foreach(println)
}
}
Sbt 文件(sbt 版本 0.13.15):
name := "HBaseScalaClient"
scalaVersion := "2.10.6"
resolvers += "Apache HBase" at "https://repository.apache.org/content/repositories/releases"
resolvers += "Thrift" at "http://people.apache.org/~rawson/repo/"
libraryDependencies ++= Seq(
"org.apache.hadoop" % "hadoop-core" % "0.20.2",
"org.apache.hbase" % "hbase" % "0.90.4"
)
编译错误:
[error] /home/user/HBaseScala/Client.scala:2: object Connection is not a member of package org.apache.hadoop.hbase.client
[error] import org.apache.hadoop.hbase.client.Connection
[error] ^
[error] /home/user/HBaseScala/Client.scala:3: object ConnectionFactory is not a member of package org.apache.hadoop.hbase.client
[error] import org.apache.hadoop.hbase.client.ConnectionFactory
[error] ^
[error] /home/user/HBaseScala/Client.scala:9: not found: value ConnectionFactory
[error] val connection = ConnectionFactory.createConnection(conf)
[error] ^
[error] three errors found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 1 s, completed May 12, 2017 3:30:48 PM
任何想法我缺少什么或这段代码有什么问题?
【问题讨论】: