gpt4 book ai didi

java - 无法在 gradle 项目中运行测试,错误为 : 'Could not create the Java Virtual Machine'

转载 作者:行者123 更新时间:2023-12-02 10:19:16 24 4
gpt4 key购买 nike

我正在尝试在 gradle 项目中执行测试。但是当我尝试在 Intellij 中使用“gradle test”执行测试时,它失败了。

我尝试过的

  1. 使用“gradle clean build”创建并构建项目,不会出现错误

  2. 在 intellij 中打开运行配置,选择 gradle ,并使用 gradle 任务“test”创建并执行

  3. 执行新创建的gradle运行配置

我观察到的

  1. gradle 在任务“test”中失败,并出现错误“错误:无法创建 Java 虚拟机”。

  2. gradle run 也永远不会停止,除非我强行停止它

  3. 它还不断打印“gradle executor 1(,2,3 and so on)executing , failed”

我正在使用 java 9 、 intellij 、 gradle 。

最佳答案

我正在 IntelliJ 中使用 gradle 运行 Kotlin 项目。

------------------------------------------------------------
Gradle 5.2.1
------------------------------------------------------------

Build time: 2019-02-08 19:00:10 UTC
Revision: f02764e074c32ee8851a4e1877dd1fea8ffb7183

Kotlin DSL: 1.1.3
Kotlin: 1.3.20
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 11.0.2 (Amazon.com Inc. 11.0.2+9-LTS)
OS: Mac OS X 10.14.3 x86_64

遇到类似的问题,但具体来说:

Task :run FAILED
Unrecognized option: -d64
Error: Could not create the Java Virtual Machine.
...

为了解决我的问题,我基本上必须为我的 IntelliJ 选择正确的 JDK。

To switch the Java runtime used to run IntelliJ IDEA:

On the Help menu, click Find Action, or press ⇧⌘A.

Find and select the Switch Boot JDK action.

Select the desired JDK and click OK.

找到了这个有帮助的资源! https://www.jetbrains.com/help/idea/tuning-the-ide.html

如果万一您选择了错误的 JDK 版本,并且 IDE 不再启动,请删除 idea.jdk 文件:https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under?page=3

关于java - 无法在 gradle 项目中运行测试,错误为 : 'Could not create the Java Virtual Machine' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54454758/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com