hbasetestinguility在微型集群中是否工作?

8yparm6h  于 2021-06-09  发布在  Hbase
关注(0)|答案(1)|浏览(397)

我有一个简单的单元测试,我想针对 HBaseTestingUtility 微型集群。运行测试所需的可传递依赖项 HBaseTestingUtility 都不见了。我一直在追踪 NoClassDefFoundErrors 在打包某个jar文件时遇到了错误。错误如下: java.lang.NoClassDefFoundError: org/apache/hadoop/hbase/test/MetricsAssertHelper at org.apache.hadoop.hbase.MiniHBaseCluster.<init>(MiniHBaseCluster.java:91) 在项目的.jar文件中搜索MetricAssertHelper时,我在meta inf/services目录下找到了该文件: jar tvf org/apache/hbase/hbase-hadoop2-compat/1.0.0/hbase-hadoop2-compat-1.0.0-tests.jar | grep MetricsAssertHelper 53 Sat Feb 14 19:43:40 MST 2015 META-INF/services/org.apache.hadoop.hbase.test.MetricsAssertHelper 1337 Sat Feb 14 19:43:40 MST 2015 org/apache/hadoop/hbase/test/MetricsAssertHelperImpl$MockMetricsBuilder.class 3743 Sat Feb 14 19:43:40 MST 2015 org/apache/hadoop/hbase/test/MetricsAssertHelperImpl$MockRecordBuilder.class 6689 Sat Feb 14 19:43:40 MST 2015 org/apache/hadoop/hbase/test/MetricsAssertHelperImpl.class 但是,这不是.class文件。我想知道 MetricsAssertHelper.class .jar文件中缺少文件,因为其中有一个“metricasserthelperimpl.class文件”。
这是我的代码和mvn依赖项。错误发生在 HBaseTestingUtility.startMiniCluster() 打电话。

private static HBaseTestingUtility utility; 

@Before
public void setUp() throws Exception {
    utility = new HBaseTestingUtility();
    utility.startMiniCluster();
}

    <dependencies>

    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-minicluster</artifactId>
        <version>2.5.1</version>
    </dependency>

    <dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase-server</artifactId>
        <version>1.0.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase-server</artifactId>
        <version>1.0.0</version>
        <type>test-jar</type>
    </dependency>
    <dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase-hadoop2-compat</artifactId>
        <version>1.0.0</version>
        <scope>test</scope>
        <type>test-jar</type>
    </dependency>

</dependencies>
rqdpfwrv

rqdpfwrv1#

问题是我还需要一个 hbase-hadoop-compat 除了 hbase-hadoop2-compat . 下面是使用hbasetestinguility minicluster运行junit测试所需的依赖项的完整列表。

<dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-minicluster</artifactId>
        <version>2.5.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase-server</artifactId>
        <version>1.0.0</version>
        <type>test-jar</type>
    </dependency>
    <dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase-hadoop-compat</artifactId>
        <version>1.0.0</version>
        <scope>test</scope>
        <type>test-jar</type>
    </dependency>
    <dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase-hadoop2-compat</artifactId>
        <version>1.0.0</version>
        <scope>test</scope>
        <type>test-jar</type>
    </dependency>
    <dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase-server</artifactId>
        <version>1.0.0</version>
        <scope>test</scope>
    </dependency>

相关问题