HBase dependencies with SBT in Scala

柔情痞子 提交于 2020-01-24 19:57:04

问题


I am new with Scala, SBT and Intellij.

Using the following sbt file :

name := "mycompany"

version := "0.0.1-SNAPSHOT"

scalaVersion := "2.11.8"

libraryDependencies ++= Seq(
  "org.apache.spark" %% "spark-core" % "2.0.1",
  "org.apache.spark" %% "spark-sql" % "2.0.1",
  "org.apache.spark" %% "spark-mllib" % "2.0.1",
  "org.apache.hbase" % "hbase-client" % "1.2.0",
  "com.typesafe.akka" %% "akka-http-experimental" % "2.4.11"
)

resolvers ++= Seq(
  "Apache Repository" at "https://repository.apache.org/content/repositories/releases/"
)

The three Apache Spark dependencies are red underlined in Intellij with an 'Unreasolved dpendancy' tag. However, I can import Spark libraries and my Spark jobs run in local mode without any issue.

I can not import from the HBase library inside the IDE. The following imports all can not be resolved

import org.apache.hadoop.hbase.HBaseConfiguration
import org.apache.hadoop.hbase.KeyValue
import org.apache.hadoop.hbase.MasterNotRunningException;
import org.apache.hadoop.hbase.TableName
import org.apache.hadoop.hbase.ZooKeeperConnectionException
import org.apache.hadoop.hbase.client.Connection
import org.apache.hadoop.hbase.client.ConnectionFactory
import org.apache.hadoop.hbase.client.Get
import org.apache.hadoop.hbase.client.Result
import org.apache.hadoop.hbase.client.Table
import org.apache.hadoop.hbase.util.Bytes

I have written code in java using the above imports without any issue and only with these lines in maven:

    <dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase-client</artifactId>
        <scope>provided</scope>
        <version>1.2.0</version>
    </dependency>

What am I doing wrong ?

Thanks

EDIT

Thanks to pamu's post, I have replaced the resolvers with:

resolvers ++= Seq(
  "Apache Repository" at "https://repository.apache.org/content/repositories/releases/",
  "Cloudera repo" at "//repository.cloudera.com/artifactory/cloudera-repos/"
)

However, I still have some unresolved imports (other above are now OK):

import org.apache.hadoop.hbase.HBaseConfiguration
import org.apache.hadoop.hbase.KeyValue
import org.apache.hadoop.hbase.util.TableName
import org.apache.hadoop.hbase.util.Bytes

Thanks for your help

EDIT

libraryDependencies ++= Seq(
  "org.apache.hbase" % "hbase-server" % 1.2.1,
  "org.apache.hbase" % "hbase-client" % 1.2.1,
  "org.apache.hbase" % "hbase-common" % 1.2.1,
  "org.apache.hadoop" % "hadoop-common" % 2.7.3
)

回答1:


In mentioned hbase lib with version 1.2.0 there are not such classes. You can check using jar -tvf. Those classes exists in 2.0.0 (sure) hbase API



来源:https://stackoverflow.com/questions/40386301/hbase-dependencies-with-sbt-in-scala

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!