Intellij Idea Gradle版本/ Gradle JVM与JDK兼容,仍收到不支持的类主文件版本61错误

toe95027  于 2023-06-21  发布在  其他
关注(0)|答案(1)|浏览(409)

我已经检查了这个IntelliJ gradle project error "Unsupported class file major version 61",不幸的是它不能解决我的问题。
我使用Intellij-idea。我查看Oracle文档,发现Java 15.0.2与Gradle版本6.7兼容,但仍然收到不支持的类主文件版本61
另外,我以前使用的是JDK 17,但后来我卸载了它,并将Java_Home设置为JDK 15。
Gradle版本的详细信息下载在我的PC上

------------------------------------------------------------
Gradle 6.7
------------------------------------------------------------

Build time:   2020-10-14 16:13:12 UTC
Revision:     312ba9e0f4f8a02d01854d1ed743b79ed996dfd3

Kotlin:       1.3.72
Groovy:       2.5.12
Ant:          Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM:          15.0.2 (Oracle Corporation 15.0.2+7-27)
OS:           Windows 10 10.0 amd64

我正在使用的JDK的详细信息:

java version "15.0.2" 2021-01-19
Java(TM) SE Runtime Environment (build 15.0.2+7-27)
Java HotSpot(TM) 64-Bit Server VM (build 15.0.2+7-27, mixed mode, sharing)

我仔细检查了项目结构>>项目>>我用的JDK版本,也是15。
我还仔细检查了设置>>构建工具>> Gradle>> Gradle JVM,也是15。
我还仔细检查了gradle>> www.example.com文件,看看版本是否为6.7,它是7.5.1,但我将其修复为6.7(在stackOverflow上搜索时看到了这一点,我希望这是正确的方法)gradle-wrapper.properties**file to see if version is 6.7 there, it was 7.5.1 but I fixed it to 6.7 (saw this upon searching on stackOverflow, i hope it is right way to do this)
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
我还将目标和源兼容性更改为15,如下所示:

// Set the JVM compatibility versions
    withType<JavaCompile> {
        sourceCompatibility = "15"
        targetCompatibility = "15"

尽管如此,我还是收到了这个错误。如何解决这个问题?

    • Intellij更新到2023.1.2后**
  1. Gradle Package 器属性:
    distributionBase = GRADLE_USER_HOME distributionPath = wrapper/dists distributionUrl = https://www.example.com www.example.com zipStoreBase = GRADLE_USER_HOME zipStorePath = wrapper/dists services.gradle.org/distributions/gradle-7.6-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists
    1.* * 插件和依赖部分:**
    插件{id("java")id("org. jetbrains. intellij")version "1.14.1 "}
    group ="com. plugin" version ="1.0-SNAPSHOT"
    存储库{mavenCentral()}
    //配置Gradle IntelliJ插件//阅读更多:https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij {version. set("2023.1.2")type. set("IC")//目标IDE平台
plugins.set(listOf(/* Plugin Dependencies */))

}
tasks {//使用Type {sourceCompatibility ="20" targetCompatibility ="20 "}设置JVM兼容版本

patchPluginXml {
     sinceBuild.set("221")
     untilBuild.set("231.*")
 }

 signPlugin {
     certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
     privateKey.set(System.getenv("PRIVATE_KEY"))
     password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
 }

 publishPlugin {
     token.set(System.getenv("PUBLISH_TOKEN"))
 }

}

kt06eoxx

kt06eoxx1#

唯一的解决方法就是:已将Intellij更新到最新版本(2023.1.2)添加了Gradle 8.1.1(最新的Gradle版本)使用最新的JDK和JVM(20)

相关问题