Mojo执行异常

MojoExecution exception

我在用maven编译hadoop源代码时出现这个错误。

我正在使用 windows 8.1、hadoop 2.7.2 和 visual studio 2012。

我按照这个 link Maven MojoExecutionException 但是它没有用。

为了安装 hadoop,我使用 http://harishshan.blogspot.com/2014/10/install-hadoop-251-on-windows-7-64bit.html

[ERROR] Failed to execute goal org.apache.hadoop:hadoop-maven-plugins:2.7.2:prot
oc (compile-protoc) on project hadoop-common: org.apache.maven.plugin.MojoExecut
ionException: 'protoc --version' did not return a version -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command

[ERROR]   mvn <goals> -rf :hadoop-common

异常与Maven无关。报错信息其实已经指向了主要问题:

[ERROR] Failed to execute goal org.apache.hadoop:hadoop-maven-plugins:2.7.2:protoc \
(compile-protoc) on project hadoop-common: \
org.apache.maven.plugin.MojoExecutionException: \
'protoc --version' did not return a version -> [Help 1]

org.apache.hadoop:hadoop-maven-pluginsMaven Plugin的protoc目标是检查PATH中是否有protoc命令,检查最简单的常用命令:版本命令:

protoc --version

查看 tutorial you linked 您很可能错过了第 4 步:

Step 4: Install Protocol buffer 2.5.0

或者您可能没有正确配置它,没有通过命令 PATH 使其可用。


更新
该教程确实没有提供太多关于从哪里以及如何安装 Protocol Buffer 的信息。

教程描述的版本是2.5.0,可用here. You can download the Windows zip here。然后简单地解压缩它并将其路径添加到 Windows PATH:在检查 Maven 构建是否会识别它之前,首先检查 protoc --version 是否可以从任何命令行正常。


另请注意:对教程的评论也指向其他错误,请仔细检查它们以防您在整个过程中仍然遇到其他错误。