此环境中未提供编译器。也许您是 运行 JRE 而不是 JDK?在 visual studio 代码中

No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? in visual studio code

下面是vscode中的配置。 虽然我在 vscode 中配置了 JDK,但当我 运行 maven install 但 maven test 工作正常时,我仍然遇到编译错误..

请指教如何解决。

您无需配置 "maven.terminal.useJavaHome",它取决于 java.home,但 java.home 目前已弃用。

Official docs:

If you need to compile your projects against a different JDK version, it's recommended you configure the java.configuration.runtimes property in your user settings, eg:

"java.configuration.runtimes": [
  {
    "name": "JavaSE-1.8",
    "path": "/path/to/jdk-8",
  },
  {
    "name": "JavaSE-11",
    "path": "/path/to/jdk-11",
  },
  {
    "name": "JavaSE-18",
    "path": "/path/to/jdk-18",
    "default": true
  },
]

但不会修改终端中的Path环境变量,会影响Java扩展,例如Run Java按钮。

而且从你问题中的图片和你的评论来看,你需要先下载安装一个JDK,记得把JDK的bin文件夹添加到Path环境中变量。