使用Intellij IDEA构建项目时,Maven Surefire插件出现“启动分叉错误”的问题。

7

我试图使用Intellij IDEA和Maven构建Java插件,但是遇到了错误:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.803 s
[INFO] Finished at: 2015-06-16T16:34:55-10:00
[INFO] Final Memory: 17M/216M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project mc-hyperchat: Error occurred in starting fork, check output in log -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

我了解这是因为这行代码(我使用-X标志找到了它)。
Forking command line: cmd.exe /X /C ""D:\Program Files\Java\jdk1.8.0_45\jre\bin\java" -jar C:\Users\<username>\Documents\+GIT\mc-hyperchat\target\surefire\surefirebooter8505511050498586005.jar C:\Users\<username>\Documents\+GIT\mc-hyperchat\target\surefire\surefire5990474653240919844tmp C:\Users\<username>\Documents\+GIT\mc-hyperchat\target\surefire\surefire_08408900793313340679tmp"
The system cannot find the path specified.

我偶然遇到了另一个人有完全相同的问题:

Maven Surefire 2.13在Windows上无法分叉

接受的答案似乎是他的JAVA_HOME环境变量无效,所以我检查了我的:

enter image description here

我还在命令提示符上回显了变量,以确保它没有任何引号(我还运行了cmd.exe以查看另一个系统找不到指定的路径消息):

enter image description here

我确信我的JAVA_HOME环境变量是正确的。如果是这样,还有什么其他原因导致这个问题?

1个回答

17

我发现这是一个与Windows相关的错误 -

打开注册表编辑器 导航到 HKCU\Software\Microsoft\Command Processor\AutoRun 并清除值。 还要检查 HKLM\Software\Microsoft\Command Processor\AutoRun。


1
因为这个问题,我浪费了整整一天。非常棒的解决方案。谢谢。 - Olcay Tarazan
我简直不敢相信这个能行。突然想起来为什么我转向使用Gradle了。 - user1094865
2
对我也起作用了,我在那个条目中安装了6个月前阅读和练习《Java黄瓜》书时安装的ansicon。 - Char
嘿@miconico,你的解决方案对我也有效。你能否分享一下你是如何排除问题并确定该问题与注册表中的AutoRun值有关的方法?谢谢。 - ThangLeQuoc
2
又是一个“对我有用”的例子。最近我卸载Anaconda失败了,我的HKCU AutoRun中有“C:\ProgramData\Anaconda3\condabin\conda_hook.bat”。 - D Rickard
同样在AutoRun注册表键的值中也有ansicon。 - Angle.Bracket

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接