0

我正在编写 map reduce 程序来比较两个文件。当我运行程序时,它会抛出以下异常。

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
at org.apache.hadoop.metrics2.lib.MutableMetricsFactory.getName(MutableMetricsFactory.java:119)

我的 pom 文件。

 <dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>0.20.2</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-mapreduce-client-core</artifactId>
<version>0.23.1</version>
</dependency>
<dependency>
    <artifactId>guava</artifactId>
    <groupId>com.google.guava</groupId>
    <type>jar</type>
    <version>15.0</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
 <dependency>
 <groupId>org.apache.commons</groupId>
 <artifactId>commons-lang3</artifactId>
 <version>3.3</version>
  </dependency>
 <dependency>
  <groupId>commons-logging</groupId>
 <artifactId>commons-logging</artifactId>
 <version>1.1.1</version>
 </dependency>
</dependencies>

任何帮助将不胜感激。

4

1 回答 1

6

正如错误消息java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils告诉您的那样,您需要添加 commons-lang 作为依赖项:

<!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
<dependency>
    <groupId>commons-lang</groupId>
    <artifactId>commons-lang</artifactId>
    <version>2.3</version>
</dependency>

您添加了commons-lang3它也有一个 StringUtils 类,但带有包名org/apache/commons/lang3/StringUtils

于 2016-12-09T07:45:04.407 回答