HBase with Scala class 无法导入连接*
HBase with Scala class Connection* cannot be imported
我正在尝试编译 运行 来自 Hbase 文档的 scala 示例 http://hbase.apache.org/1.2/book.html#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
知道我遗漏了什么或这段代码有什么问题吗?
尝试使用此库依赖项:
libraryDependencies ++= Seq(
"org.apache.hadoop" % "hadoop-core" % "1.2.1",
"org.apache.hbase" % "hbase" % "1.2.0",
"org.apache.hbase" % "hbase-client" % "1.2.0",
"org.apache.hbase" % "hbase-common" % "1.2.0",
"org.apache.hbase" % "hbase-server" % "1.2.0"
)
并添加此导入:
import org.apache.hadoop.hbase.HBaseConfiguration
import org.apache.hadoop.hbase.client.{ConnectionFactory,HBaseAdmin,HTable,Put,Get}
import org.apache.hadoop.hbase.util.Bytes
我正在尝试编译 运行 来自 Hbase 文档的 scala 示例 http://hbase.apache.org/1.2/book.html#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
知道我遗漏了什么或这段代码有什么问题吗?
尝试使用此库依赖项:
libraryDependencies ++= Seq(
"org.apache.hadoop" % "hadoop-core" % "1.2.1",
"org.apache.hbase" % "hbase" % "1.2.0",
"org.apache.hbase" % "hbase-client" % "1.2.0",
"org.apache.hbase" % "hbase-common" % "1.2.0",
"org.apache.hbase" % "hbase-server" % "1.2.0"
)
并添加此导入:
import org.apache.hadoop.hbase.HBaseConfiguration
import org.apache.hadoop.hbase.client.{ConnectionFactory,HBaseAdmin,HTable,Put,Get}
import org.apache.hadoop.hbase.util.Bytes