【发布时间】:2016-05-26 09:40:14
【问题描述】:
我正在尝试使用 scala 代码探索 HBase API 所以我想根据here - Official Scala documentation 的引用设置一个简单的独立 scala 项目(使用 SBT)。这是我的 build.sbt
name := "hbase-sandbox"
version := "1.0"
scalaVersion := "2.10.4"
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" % "*" % "2.7.1",
"org.apache.hbase" % "hbase-client" % "1.1.2"
)
这是文档中提到的代码
import org.apache.hadoop.hbase.HBaseConfiguration
import org.apache.hadoop.hbase.client.{Connection,ConnectionFactory,HBaseAdmin,HTable,Put,Get}
import org.apache.hadoop.hbase.util.Bytes
object Main extends App {
val conf = new HBaseConfiguration()
val connection = ConnectionFactory.createConnection(conf)
val admin = connection.getAdmin()
// list the tables
val listtables=admin.listTables()
listtables.foreach(println)
// let's insert some data in 'mytable' and get the row
val table = new HTable(conf, "mytable")
val theput= new Put(Bytes.toBytes("rowkey1"))
theput.add(Bytes.toBytes("ids"),Bytes.toBytes("id1"),Bytes.toBytes("one"))
table.put(theput)
val theget= new Get(Bytes.toBytes("rowkey1"))
val result=table.get(theget)
val value=result.value()
println(Bytes.toString(value))
}
错误/异常
Error:(1, 8) object HBaseConfiguration is not a member of package org.apache.hadoop.hbase
import org.apache.hadoop.hbase.HBaseConfiguration
^
Error:(3, 8) object Bytes is not a member of package org.apache.hadoop.hbase.util
import org.apache.hadoop.hbase.util.Bytes
^
Error:(6, 18) not found: type HBaseConfiguration
val conf = new HBaseConfiguration()
^
我无法使用 hbase 下载 hadoop。 sbt 无法解决依赖关系。我已经尝试了 Hadoop 和 Hbase 版本的各种组合。而且org.apache.hbase#hbase~1.1.2jars在apache repository中不存在
如果我没有走上正确的道路,那么设置一个简单的 SBT 项目以在 scala 中试验 HBase API 的正确方法应该是什么。
更新
具有相同依赖版本的相同代码与 Maven 项目一样工作所以我猜问题出在一些 SBT 依赖解析器或类似的东西上。
【问题讨论】:
标签: apache scala hadoop sbt hbase