Gradle 5和IntelliJ 2018.3.无法识别的选项:--add-opens或java.base.java.lang = ALL-UNNAMED [英] Gradle 5 and IntelliJ 2018.3. Unrecognized option: --add-opens or java.base.java.lang=ALL-UNNAMED

查看:4086
本文介绍了Gradle 5和IntelliJ 2018.3.无法识别的选项:--add-opens或java.base.java.lang = ALL-UNNAMED的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组由Gradle 4.10.3构建的复杂项目.我可以从命令行构建它们,但也可以将它们导入到IntelliJ 2018.3 Ultimate中,而不会出现重大问题.

I have a complex set of projects built by Gradle 4.10.3. I can build them from the command line, but I can also import them to IntelliJ 2018.3 Ultimate without major issues.

当我将Gradle升级到5.1.1时,项目仍然可以从控制台正常构建,但是我无法再在IntelliJ中导入(或刷新)项目:(

When I upgrade my Gradle to 5.1.1, the projects are still building fine from the console, however I can no longer import (or refresh) the project in IntelliJ :(

配置部分运行正常,但是守护进程无法在IntelliJ中启动.如果我在IntelliJ项目设置中将Gradle JVM设置为Java 8,则会收到错误消息:

The configuration part goes fine, but the daemon process could not be started within IntelliJ. If I set Gradle JVM to Java 8 in the IntelliJ project settings, I get an error:

Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Unrecognized option: --add-opens

如果我在IntelliJ项目设置中将Gradle JVM设置为Java 11,则会收到另一个错误:

If I set Gradle JVM to Java 11 in the IntelliJ project settings, I get a different error:

Error: Could not find or load main class java.base.java.lang=ALL-UNNAMED
Caused by: java.lang.ClassNotFoundException: java.base.java.lang=ALL-UNNAMED

一旦我执行gradlew wrapper --gradle-version=4.10.3(将包装器改回4.10.3),IntelliJ插件就会再次正常工作.

As soon as I execute gradlew wrapper --gradle-version=4.10.3 (change back the wrapper to 4.10.3), the IntelliJ plugin works fine again.

如果我将gradle idea任务(idea gradle插件)添加到脚本中,则它也可以在控制台上使用5.1.1版本正常运行.

If I add gradle idea task (idea gradle plugin) to the scripts, it executes fine from the console also with the version 5.1.1.

从用户文件夹中删除.idea设置没有帮助.干净导入也无济于事.尝试IntelliJ中与Gradle相关的所有可能的设置(包括所有与包装相关的设置).什么都没有帮助:(

Removing .idea settings from the user folder did not help. Clean import did not help either. All possible settings inside IntelliJ related to Gradle (including all wrapper-related settings) are tried. Nothing helped :(

问题似乎很简单,但是由于几天来我找不到解决方法:(这些--add-opens的来源来自哪里?如何防止这种情况发生?

The problem seems to be so trivial, however I cannot find a solution since few days :( Where those --add-opens are coming from? How to prevent this?

推荐答案

原因是用户主目录.gradle文件夹中的gradle.properties文件.只需删除文件即可解决IntelliJ的问题.

The cause was the gradle.properties file in the .gradle folder in the user home. Just removing the file solves this problem with IntelliJ.

还是很高兴知道造成这种情况的原因...

Still it would be nice to know the cause of this...

非常奇怪的错误!

积分: IntelliJ IDEA Gradle同步:问题将Gradle的Java主页设置为某些JDK

这篇关于Gradle 5和IntelliJ 2018.3.无法识别的选项:--add-opens或java.base.java.lang = ALL-UNNAMED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆