3

我在 Ubuntu 12.04 中运行 Maven 3.0.4。我有 Java 版本 1.7.0_25。我正在尝试使用该mvn package命令,但不断遇到错误,这些错误总是如下:

Failure executing javac, but could not parse the error:
javac: directory not found: /......../target/[some folder]

我无法弄清楚这最初是什么,但现在通过一些基本的谷歌搜索了解到这是因为目标目录必须存在。通常建议的处理这个问题的方法是创建一个 ant 脚本来为你做这件事(我认为)。

但是,我不知道实际需要创建哪些文件夹。这不是我正在编译的项目,只是我下载的东西。是否仍然可以使用 Ant 脚本,如果是这样,任何人都可以指出我正确的方向,因为我以前从未使用过 Ant 脚本,更不用说创建了,并且可以非常准确地称为 Ubuntu“noob”!

按要求提供完整的 Maven 输出

目录是:

flume-sources - containing
    flume.conf
    pom.xml
    src
      main
        java
          com
            cloudera
              flume
                source
                  TwitterSource.java
                  TwitterSourceConstants.java

Maven错误是:

andrew@andrew-VirtualBox:~/flume-sources$ mvn package
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building flume-sources 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) @ flume-sources ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/andrew/flume-sources/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ flume-sources ---
[INFO] Compiling 2 source files to /home/andrew/flume-sources/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Failure executing javac, but could not parse the error:
javac: directory not found: /home/andrew/flume-sources/target/classes
Usage: javac <options> <source files>
use -help for a list of possible options

[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.470s
[INFO] Finished at: Mon Jul 08 12:35:58 BST 2013
[INFO] Final Memory: 9M/59M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project flume-sources: Compilation failure
[ERROR] Failure executing javac, but could not parse the error:
[ERROR] javac: directory not found: /home/andrew/flume-sources/target/classes
[ERROR] Usage: javac <options> <source files>
[ERROR] use -help for a list of possible options
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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 read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
andrew@andrew-VirtualBox:~/flume-sources$ 
4

1 回答 1

5

不,您不需要手动或使用 ant 脚本创建文件夹。

如果target运行 mvn 时该文件夹不存在,它将创建它

所以我的猜测是你有权限问题

运行 maven 的用户无法在 /home/andrew/flume-sources 中创建文件夹

只是作为测试,以 root 身份运行 mvn

 sudo mvn package

如果可行,那么这就是我所说的,您将需要 1)chown该文件夹,以便运行 maven 的用户可以在其中创建文件夹(rw)或 2)从拥有该文件夹的同一用户运行 mvn(我是猜测是andrew

于 2013-07-08T20:10:52.330 回答