这怎么不能在 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”调用 cmd 作为可执行文件(告诉 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/