有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

VisualStudio代码如何获取任务的java参考库列表。vscode中的json

我使用“ProjectManagerforJava”来帮助我管理项目中引用的库。当我尝试在vscode中使用Task时,我不知道如何获取“args”中所有参考库的列表。 例如,我有这样的任务。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",
    "tasks": [
        {
            "label": "javac",
            "type": "shell",
            "command": "javac",
            "args": [
                "-cp",
                "${library}/*.jar",
                "${workspaceRoot}/*.java"
            ]
        }
    ]
}

共 (1) 个答案

  1. # 1 楼答案

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

    enter image description here

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

    同样根据predefined variables,变量${workspaceRoot}deprecated,有利于${workspaceFolder}更好地与多根工作区支持保持一致