我了解到Exec插件有两个目标,exec:exec和exec:java,但我不知道如何指定它们:
在我的例子中,mvn exec:java工作得很好,但是mvn exec:exec总是抛出异常,如下所示:
[INFO] --- exec-maven-plugin:1.6.0:exec (run) @ allnewmaker --- [ERROR] Command execution failed. java.io.IOException: Cannot run program "exec" (in directory "/home/huang/Desktop/Project/Make/allnewmaker"): error=2, No such file or directory at java.lang.ProcessBuilder.start (ProcessBuilder.java:1048) at java.lang.Runtime.exec (Runtime.java:620) at org.apache.commons.exec.launcher.Java13CommandLauncher.exec (Java13CommandLauncher.java:61) at org.apache.commons.exec.DefaultExecutor.launch (DefaultExecutor.java:279) at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:336) at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166) at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:804) at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:751)
我的pom.xml是这样的
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>bar</id>
<goals>
<goal>exec</goal>
</goals>
</execution>
<execution>
<id>foo</id>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<!--default: java-->
<executable>exec</executable>
<arguments>
<argument>-i</argument>
<argument>${argInput}</argument>
<argument>-o</argument>
<argument>${argOutput}</argument>
</arguments>
<mainClass>org.qoros.maker.AllNewMaker</mainClass>
</configuration>
</plugin>
</plugins>发布于 2018-04-23 10:20:42
在pom中,您有可执行文件的名称: exec,而名称"exec“不是有效的可执行文件名。
您可以在那里配置目标:
<execution>
<id>bar</id>
<goals>
<goal>exec</goal>
</goals>
</execution>如果要使用exec: java,则需要将目标从exec更改为java。
我指的是使用页面:https://www.mojohaus.org/exec-maven-plugin/usage.html
如果有什么需要澄清的话,请告诉我!
https://stackoverflow.com/questions/49978053
复制相似问题