这个错误是因为你正在使用 Java 11 的 preview API,而它默认是被禁用的。要解决这个问题,你需要在编译和运行时开启 preview API。

在编译时,你需要添加 --enable-preview 标志来开启 preview API。例如:

javac --enable-preview MyClass.java

在运行时,你需要添加 --enable-preview 标志来开启 preview API。例如:

java --enable-preview MyClass

如果你使用的是 Maven 或 Gradle 等构建工具,你可以在配置文件中添加以下内容来开启 preview API:

Maven:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <compilerArgs>--enable-preview</compilerArgs>
            </configuration>
        </plugin>
    </plugins>
</build>

Gradle:

tasks.withType(JavaCompile) {
    options.compilerArgs << "--enable-preview"
}
``
idea 报错 如何配置 java newVirtualThreadPerTaskExecutor is a preview API and is disabled by default use --enable-preview to enable preview APIs

原文地址: https://www.cveoy.top/t/topic/fXVK 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录