错误:使用 –enable-preview 无效的源版本发布 14。

huangapple go评论64阅读模式
英文:

error: invalid source release 14 with --enable-preview

问题

我正在使用Micronaut 2.0.2应用程序与IntelliJ IDE 2020.2.2。我已在IDE中从语言级别启用了预览功能。

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

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

tasks.withType(JavaCompile) {
    options.encoding = "UTF-8"
    options.compilerArgs.addAll([
            '-parameters',
            // 启用增量编译
            '-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

英文:

I am using Micronaut2.0.2 application with IntelliJ IDE 2020.2.2. I have enabled the preview feature in from the language level in IDE

错误:使用 –enable-preview 无效的源版本发布 14。

And in the Gradle file I have the below option

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"
    ])
}

Getting an error as error: invalid source release 14 with --enable-preview

答案1

得分: 5

将设置(macOS上的首选项)设置为 | 构建、执行、部署 | 构建工具 | Gradle | 将 Gradle JVM 设置为 JDK 14 版本。

英文:

Set Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Gradle | Gradle JVM to 14 JDK version.

答案2

得分: 3

如果您的 pom.xml 中有一些错误的配置,类似这样的,请将其删除。在我删除这些配置后,它对我起效了:

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

这就是对我造成干扰的部分。因为我已经安装了 Java 16。

英文:

If you have some wrong configurations in your pom.xml like this remove it. It worked for me after I remove the configs:

    &lt;configuration&gt;
        &lt;source&gt;15&lt;/source&gt;
        &lt;target&gt;15&lt;/target&gt;
        &lt;compilerArgs&gt;--enable-preview&lt;/compilerArgs&gt;
    &lt;/configuration&gt;

That's what was messing up for me. Since I already have Java 16 already.

huangapple
  • 本文由 发表于 2020年10月2日 01:31:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/64160463.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定