修复 "Configuration cannot be resolved to a type"

Fixing "Configuration cannot be resolved to a type"

全部,

我正在尝试 HBase tutorial 并使用 Eclipse 作为我的 IDE。 以下 1 行代码是问题所在,但我不知道为什么。

Configuration config = HBaseConfiguration.create();

Eclipse 出错

Configuration cannot be resolved to a type
  1. 我从我的 $HBASE_HOME/lib
  2. 导入了所有 jar
  3. 我正在使用 HBase 1.2.5

截图

HBase 1.2.5中没有Configurationclass部分,大家可以翻一下JavaDoc and you will see it's not there. What is being returned from the method HBaseConfiguration.create(); is actually of type org.apache.hadoop.conf.Configuration which is part of Apache Hadoop Main。您还需要将该包导入到您的项目中。

备注

在 Eclipse 中,如果您将鼠标悬停在 class 上,它无法解析,它将提供有关您可以导入哪些 class 的建议。如果您在那里没有看到它,那是因为 class 不存在于您的 class 路径中。