Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Maven文件路径参数执行器_Java_Maven_Exec Maven Plugin - Fatal编程技术网

Java Maven文件路径参数执行器

Java Maven文件路径参数执行器,java,maven,exec-maven-plugin,Java,Maven,Exec Maven Plugin,这是我的文件结构 ├── algs4-data ├── src │ ├── main │ └── test └── target ├── classes ├── maven-archiver ├── surefire ├── surefire-reports └── test-classes . ├── src │   ├── main │   │   ├── java │   │   │   └── edu │   │   └── resour

这是我的文件结构

├── algs4-data
├── src
│   ├── main
│   └── test
└── target
    ├── classes
    ├── maven-archiver
    ├── surefire
    ├── surefire-reports
    └── test-classes
.
├── src
│   ├── main
│   │   ├── java
│   │   │   └── edu
│   │   └── resources
│   │       └── algs4-data
│   └── test
│       └── java
│           └── edu
└── target
    ├── classes
    │   ├── algs4-data
    │   └── edu
    │       └── princeton
    ├── maven-archiver
    ├── site
    │   ├── css
    │   └── images
    │       └── logos
    ├── surefire
    ├── surefire-reports
    └── test-classes
        └── edu
            └── princeton
我想用path参数和管道传递文件名。但我失败了,我怎么能做到

mvn exec:java -Dexec.mainClass="edu.princeton.cs.algs4.BinarySearch" \
   -Dexec.args="algs4-data/tinyW.txt < algs4-data/tinyT.txt"

使用文件结构时,algs4数据不可见。启动应用程序时,执行的根目录是目标文件夹。通过不将algs4数据放入/src/main/resources这样的src文件夹,它就不会被复制到target/classes中


解决方案应该在不知道代码和测试的情况下在imo中工作:将algs4数据复制到src/main/resources

使用文件结构algs4数据不可见。启动应用程序时,执行的根目录是目标文件夹。通过不将algs4数据放入/src/main/resources这样的src文件夹,它就不会被复制到target/classes中


解决方案应该在不知道代码和测试的情况下在imo中工作:将algs4数据复制到src/main/resources

错误消息是什么?你能发布你的Maven日志吗?错误信息是什么?你能发布你的Maven日志吗?谢谢,我同意你的建议,但是我的构建失败了,我更新了我的问题。algs4 data/tinyW.txt在target/classes中吗?是的(我更新了文件结构),可能是因为我在参数中使用了管道?你能把你的项目放在github上,我可以试着运行它吗?谢谢,我戴上了git@github.com:yu yuxuan/algs4_exercise.git谢谢,我做了你的建议,但是我的构建失败了,我更新了我的问题。algs4 data/tinyW.txt在target/classes中吗?是的(我更新了文件结构),可能是因为我在争论中使用了管道?你能把你的项目放在github上吗?谢谢,我戴上了git@github.com:yu yuxuan/algs4_exercise.git
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building algs4 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- exec-maven-plugin:1.5.0:java (default-cli) @ algs4 ---
[WARNING]
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:294)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: Could not open algs4-data/tinyW.txt
    at edu.princeton.cs.algs4.In.<init>(In.java:194)
    at edu.princeton.cs.algs4.BinarySearch.main(BinarySearch.java:91)
    ... 6 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.821s
[INFO] Finished at: Wed Jun 15 09:29:50 CDT 2016
[INFO] Final Memory: 12M/94M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.5.0:java (default-cli) on project algs4: An exception occured while executing the Java class. null: InvocationTargetException: Could not open algs4-data/tinyW.txt -> [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/MojoExecutionException
.
├── src
│   ├── main
│   │   ├── java
│   │   │   └── edu
│   │   └── resources
│   │       └── algs4-data
│   └── test
│       └── java
│           └── edu
└── target
    ├── classes
    │   ├── algs4-data
    │   └── edu
    │       └── princeton
    ├── maven-archiver
    ├── site
    │   ├── css
    │   └── images
    │       └── logos
    ├── surefire
    ├── surefire-reports
    └── test-classes
        └── edu
            └── princeton