英文:
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
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:
    <configuration>
        <source>15</source>
        <target>15</target>
        <compilerArgs>--enable-preview</compilerArgs>
    </configuration>
That's what was messing up for me. Since I already have Java 16 already.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。



评论