java级联示例编译失败?

ibrsph3r  于 2021-06-03  发布在  Hadoop
关注(0)|答案(5)|浏览(391)

我在shell中键入gradle cleanJar 在instance/part1目录中。输出如下。错误是“找不到org.apache.hadoop.mapred.jobconf的类文件”。为什么编译失败?

:clean UP-TO-DATE
:compileJava
Download http://conjars.org/repo/cascading/cascading-core/2.0.1/cascading-core-2.0.1.pom
Download http://conjars.org/repo/cascading/cascading-hadoop/2.0.1/cascading-hadoop-2.0.1.pom
Download http://conjars.org/repo/riffle/riffle/0.1-dev/riffle-0.1-dev.pom
Download http://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.pom
Download http://repo1.maven.org/maven2/org/slf4j/slf4j-parent/1.6.1/slf4j-parent-1.6.1.pom
Download http://repo1.maven.org/maven2/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.pom
Download http://conjars.org/repo/thirdparty/jgrapht-jdk1.6/0.8.1/jgrapht-jdk1.6-0.8.1.pom
Download http://repo1.maven.org/maven2/org/codehaus/janino/janino/2.5.16/janino-2.5.16.pom
Download http://conjars.org/repo/cascading/cascading-core/2.0.1/cascading-core-2.0.1.jar
Download http://conjars.org/repo/cascading/cascading-hadoop/2.0.1/cascading-hadoop-2.0.1.jar
Download http://conjars.org/repo/riffle/riffle/0.1-dev/riffle-0.1-dev.jar
Download http://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar
Download http://repo1.maven.org/maven2/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar
Download http://conjars.org/repo/thirdparty/jgrapht-jdk1.6/0.8.1/jgrapht-jdk1.6-0.8.1.jar
Download http://repo1.maven.org/maven2/org/codehaus/janino/janino/2.5.16/janino-2.5.16.jar
/home/is_admin/lab/cascading/Impatient/part1/src/main/java/impatient/Main.java:50: error: cannot access JobConf
    Tap inTap = new Hfs( new TextDelimited( true, "\t" ), inPath );
                ^
  class file for org.apache.hadoop.mapred.JobConf not found
1 error
:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:

Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 22.599 secs
eit6fx6z

eit6fx6z1#

似乎找不到类,请检查生成路径项中的库。

wfsdck30

wfsdck302#

将hadoop-core-1.x.y.jar从hadoop发行版添加到path。
这对我来说是个很好的例子。我添加了eclipse构建路径。
将此添加到gradle dependencies{}部分
编译(group:'org.apache.hadoop',name:'hadoop core',version:'1.2.0')

bjp0bcyl

bjp0bcyl3#

我今天也遇到了同样的问题,我试着为不耐烦的教程级联。我已经解决了将以下内容添加到我的 build.gradledependencies 章节:

compile 'org.apache.hadoop:hadoop-client:2.3.0'

我想使用hadoop2.3.0,但我想您可以选择自己的hadoop版本。
ps:为了使用第一个 hadoop-mapred 包,则必须添加以下内容:

compile 'org.apache.hadoop:hadoop-mapred:0.22.0'

您可以在这里找到hadoop可能需要的所有回购。

w8biq8rn

w8biq8rn4#

谢谢lalit,添加下面这行代码对我来说很有用,不需要更改任何java版本。。

compile( group: 'org.apache.hadoop', name: 'hadoop-core', version: '1.2.0' )

或者,我甚至可以在类路径中添加hadoop核心jar,并在gradle路径中提到它

lmyy7pcs

lmyy7pcs5#

尝试使用Java6,gradle对Java7有一些已知的问题

相关问题