【发布时间】:2020-12-25 11:09:50
【问题描述】:
我正在尝试使用 Visual Studio Code 编译和运行基于 maven 的 Java 项目。
VSCODE 本身需要 JDK 11。我安装了 JDK 11 并将其添加为 VSCODE“Java:配置 Java 运行时”部分中的 java.home。
然而,该项目需要 Java 8。 我有 JAVA_HOME 指向的 JDK 8,并且 pom.xml 指定了
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
但是,当我编译并尝试在 VSCODE 中运行项目时,我收到了消息
Build path specifies execution environment JavaSE-1.8. There are no JREs installed in the workspace that are strictly compatible with this environment.
The compiler compliance specified is 1.8 but a JRE 11 is used.
即使 VSCODE 知道 JDK 8 是可访问的:
如何指示 VSCODE 使用 JDK 8(而不是 JDK 11)作为项目的运行时?
【问题讨论】: