IntelliJ/Gradle无法从'11 .0.1'确定Java版本 [英] IntelliJ/Gradle Could not determine java version from '11.0.1'
问题描述
我正在运行Linux Ubuntu 18操作系统.将jdk安装在自定义本地目录中.
I'm running a Linux Ubuntu 18 OS. Installed jdk in a custom local directory.
通常,IntelliJ建议您use the default gradle wrapper
.但就我而言,我希望能够在需要更新时即时更改Gradle版本.
如果您将IntelliJ与Gradle结合使用,则会遇到以下错误:
Normally, IntelliJ recommends that you use the default gradle wrapper
. But in my case, I want to be able to change the Gradle Version on the fly whenever it's due for an update.
If you use IntelliJ with Gradle, and you bump into the following error:
Could not determine java version from '11.0.1'
推荐答案
如果使用IntelliJ
If you use IntelliJ
检查:
-
导航至:
Navigate to:
File >> Settings >> Build, Execution, Deployment >> Build Tools >> Gradle
.
旁边Gradle JVM:
确保选择正确的Java版本.
Alongside Gradle JVM:
make sure you select the correct version of Java.
导航至:
右键单击项目根目录"&选择Open Module Settings
. Project Structure
窗口出现.确保您的JDK主目录路径已添加到Platform Settings >> SDKs : JDK home path
Navigate to:
Right-Click 'Project Root Directory' & Select Open Module Settings
. Project Structure
windows shows-up. Make sure your JDK home path is added to the Platform Settings >> SDKs : JDK home path
仍然在同一窗口Project Structure
下,选择与您的项目相关的正确SDK
Still, on the same window Project Structure
, select correct SDK relevant to your project under
Project Settings >> Modules : Module SDK
修复/解决方案:
导航到&打开:gradle/wrapper/gradle-wrapper.properties
&将distributionUrl版本更新为最新版本.
就我而言(在撰写本文时),我的旧版本是:
Fix/Solution:
Nvavigate to & open: gradle/wrapper/gradle-wrapper.properties
& update the distributionUrl version to the latest version.
In my case (at the time of this post), my older version was:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
我的最新版本是:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip
如下所示:
在您的build.gradle文件中,请确保您进行了设置:
In your build.gradle file make sure you set:
sourceCompatibility = 11
这篇关于IntelliJ/Gradle无法从'11 .0.1'确定Java版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!