java - Maven Exec 插件不在 Windows 上使用系统路径?

标签 java windows maven-2 maven

这怎么不能在 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上呢?

最佳答案

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

像这样:

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

关于java - Maven Exec 插件不在 Windows 上使用系统路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4047088/

相关文章:

java - curl POST 未传递 URL 参数

java - Hibernate 级联与逆向关系

windows - 无法使用 pkcs12 文件连接到 RabbitMq Broker

c# - 使用 Environment.OSVersion 确定操作系统

windows - FTP 将目录中的所有文件复制到本地目录

android - 如何在 Android 上测试库?

java - 从 Eclipse 与 mvn 测试开始的不同 JUnit 结果

java - 为什么程序员说 "pass by reference"真的是 "passing references by value?"为什么这很重要?

java - NetBeans 平台应用程序 : How to create test environment for first automated end-to-end test through GUI?

java - 使用 SharedPreferences 在 Android 应用程序中保存 String[][] 数组