【问题标题】:Maven Exec Plugin not using system path on windows?Maven Exec插件不在Windows上使用系统路径?
【发布时间】:2011-05-02 02:49:17
【问题描述】:

这在 Windows 中怎么不能工作?

   <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2</version>
    <executions>
     <execution>
      <id>deploy-dev-ssh</id>
      <phase>install</phase>
      <goals>
       <goal>exec</goal>
      </goals>
     </execution>
    </executions>
    <configuration>
     <executable>echo</executable>
     <arguments>
      <argument>hello</argument>
     </arguments>
    </configuration>
   </plugin>

我在运行它时得到这个:

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2:exec (do-this) on project <my_project_name>: Command execution failed. Cannot run program "echo" (in directory "<my_local_path>"): CreateProcess error=2, The system cannot find the file specified -> [Help 1]

为什么 echo 不在 PATH 上?

【问题讨论】:

    标签: java windows maven-2 maven


    【解决方案1】:

    你也可以在你的运行目录下创建一个echo.bat文件,并将内容设置为:

    @echo %*

    这种技术对于同时支持 Windows 和 Linux 构建环境特别方便。也许“echo”不是一个很好的例子,但你可能会遇到在 Windows 和 Linux 上都存在相同命令的情况。

    【讨论】:

      【解决方案2】:

      这里的问题是 echo 是 cmd.exe 程序的命令,它不是 Unix 中的独立进程\应用程序。为了执行您在此处尝试执行的操作,您需要使用 'echo'、'/C' 调用 cmd 作为可执行文件(告诉 cmd 您正在向它传递一个命令 - 请参阅 Windows 上的 'cmd /?'命令行。)和 'hello' 作为参数。

      像这样:

                  <configuration>
                      <executable>cmd</executable>
                      <arguments>
                          <argument>/C</argument>
                          <argument>echo</argument>
                          <argument>hello</argument>
                      </arguments>
                  </configuration>
      

      【讨论】:

        猜你喜欢
        • 2011-07-14
        • 1970-01-01
        • 1970-01-01
        • 2010-12-08
        • 1970-01-01
        • 1970-01-01
        • 2020-11-05
        • 1970-01-01
        相关资源
        最近更新 更多