如何使用MAVEN构建hortonworks / simple-yarn-app

时间:2015-02-09 08:07:17

标签: java maven hadoop yarn build-error

我是Hadoop的新手。最近我正在研究Hadoop2.6.0(Yarn)。现在,我想研究一个简单的纱线应用程序。 我找到了this simple yarn app。 但遗憾的是,当我运行mvn package时,它会显示如下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project simple-yarn-app: Compilation failure: Compilation failure:
[ERROR] /home/user/simple-yarn-app/src/main/java/com/hortonworks/simpleyarnapp/ApplicationMaster.java:[30,14] error: generics are not supported in -source 1.3
[ERROR] 
[ERROR] (use -source 5 or higher to enable generics)
[ERROR] /home/user/simple-yarn-app/src/main/java/com/hortonworks/simpleyarnapp/ApplicationMaster.java:[64,33] error: enhanced for loops are not supported in -source 1.3
[ERROR] 
[ERROR] (use -source 5 or higher to enable for-each loops)
[ERROR] /home/user/simple-yarn-app/src/main/java/com/hortonworks/simpleyarnapp/Client.java:[72,7] error: generics are not supported in -source 1.3
[ERROR] 
[ERROR] (use -source 5 or higher to enable generics)
[ERROR] /home/user/simple-yarn-app/src/main/java/com/hortonworks/simpleyarnapp/Client.java:[121,18] error: enhanced for loops are not supported in -source 1.3
[ERROR] 
[ERROR] (use -source 5 or higher to enable for-each loops)
[ERROR] /home/user/simple-yarn-app/src/main/java/com/hortonworks/simpleyarnapp/ApplicationMasterAsync.java:[35,42] error: generics are not supported in -source 1.3
[ERROR] 
[ERROR] (use -source 5 or higher to enable generics)
[ERROR] /home/user/simple-yarn-app/src/main/java/com/hortonworks/simpleyarnapp/ApplicationMasterAsync.java:[36,33] error: enhanced for loops are not supported in -source 1.3

我的MVN版本是:

Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.8.0_31, vendor: Oracle Corporation
Java home: /usr/lib/jvm/jdk1.8.0_31/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-45-generic", arch: "amd64", family: "unix"

pom.xml在这里:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.hortonworks</groupId>
  <artifactId>simple-yarn-app</artifactId>
  <version>1.1.0</version>
  <name>simple-yarn-app</name>

  <url>https://github.com/hortonworks/simple-yarn-app</url>

  <dependencies>
    <dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-yarn-client</artifactId>
      <version>2.6.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-common</artifactId>
      <version>2.6.0</version>
    </dependency>
  </dependencies>
</project>

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

最后,我找到了解决方案。构建错误是由于maven泛型,这是一个流行的谷歌搜索问题。 你需要将它添加到你的pom.xml:

<project ...>
  <dependencies>
   ...
  </dependencies>
  <build>
    <plugins>
       <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-compiler-plugin</artifactId>
           <version>2.3.1</version>
           <configuration>
               <source>1.5</source>
               <target>1.5</target>
           </configuration>
       </plugin>
    </plugins>
  </build>
</project>

这是一个链接:maven generics

谢谢!