如何在vscode中获取task.json的Java参考库列表

问题描述

我已经使用“ Java项目管理器”来帮助我管理项目中引用的库。当我尝试在vscode中使用Task时,我不知道如何获取“ args”中所有参考库的列表。 例如,我有这样的task.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0","tasks": [
        {
            "label": "javac","type": "shell","command": "javac","args": [
                "-cp","path-to-library/jar1.jar","${workspaceRoot}/*.java"
            ]
        }
    ]
}

我可以一个个地添加jar文件,但是要获取它们的列表,因为我已经将它们添加到引用的库中,这是“ Java项目管理器”的功能。 project manager for java 例如,在图像中,我当然可以使用“〜/ Documents / tomcat / apache-tomcat-9.0.38 / lib / servlet-api.jar”,但这非常不便。因此,如何获取“ args”的引用库列表,就像

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0","${library}/*.jar","${workspaceRoot}/*.java"
            ]
        }
    ]
}

解决方法

每个引用的库都将显示在设置中:

enter image description here

因此您可以在此设置中获取它们的列表。

根据predefined variables,变量${workspaceRoot}deprecated所支持,${workspaceFolder}更适合多根工作区支持。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...