首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >maven ` `exec:exec` `失败,但` `exec:java` `成功

maven ` `exec:exec` `失败,但` `exec:java` `成功
EN

Stack Overflow用户
提问于 2018-04-23 09:50:01
回答 1查看 675关注 0票数 1

我了解到Exec插件有两个目标,exec:execexec: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是这样的

代码语言:javascript
复制
    <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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-04-23 10:20:42

在pom中,您有可执行文件的名称: exec,而名称"exec“不是有效的可执行文件名。

您可以在那里配置目标:

代码语言:javascript
复制
<execution>
    <id>bar</id>
    <goals>
        <goal>exec</goal>
    </goals>
</execution>

如果要使用exec: java,则需要将目标从exec更改为java。

我指的是使用页面:https://www.mojohaus.org/exec-maven-plugin/usage.html

如果有什么需要澄清的话,请告诉我!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49978053

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档