gpt4 book ai didi

maven - 允许 Maven 在 Ubuntu 中自动创建目录

转载 作者:行者123 更新时间:2023-12-04 00:42:23 26 4
gpt4 key购买 nike

我在 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“菜鸟”!

请求的完整 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$

最佳答案

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

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

所以我猜你有权限问题

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

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

 sudo mvn package

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

关于maven - 允许 Maven 在 Ubuntu 中自动创建目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17525484/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com