错误:带有--enable-preview的无效源版本14

问题描述

我正在将Micronaut2.0.2应用程序与IntelliJ IDE 2020.2.2一起使用。我已经从IDE的语言级别启用了预览功能

enter image description here

在Gradle文件中,我具有以下选项

java {
    sourceCompatibility = JavaVersion.toVersion('14')
    targetCompatibility = JavaVersion.toVersion('14')
}

tasks.withType(JavaCompile) {
    options.encoding = "UTF-8"
    options.compilerArgs.addAll([
            '-parameters',// enables incremental compilation
            '-Amicronaut.processing.incremental=true','-Amicronaut.processing.annotations=fete.bird.*',"-Amicronaut.processing.group=$project.group","-Amicronaut.processing.module=$project.name","--enable-preview"
    ])
}

error: invalid source release 14 with --enable-preview的身份获取错误

解决方法

设置设置(在macOS上为首选项)|构建,执行,部署|生成工具|摇篮| 将JVM 升级到14个JDK版本。

,

如果您的 pom.xml 中有一些错误的配置,请删除它。删除配置后它对我有用:

    <configuration>
        <source>15</source>
        <target>15</target>
        <compilerArgs>--enable-preview</compilerArgs>
    </configuration>

这就是我搞砸的地方。因为我已经有了 Java 16。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...