如何创建 vs-code 任务以在 tomcat 扩展上部署 WAR 文件?

我正在从 Eclipse 迁移到 VS-Code,我正试图快速完成部署过程。我想创建一个 vs-code 任务来部署 WAR 文件。我正在使用命令adashen.vscode-tomcat:tomcat.war.run但它似乎不起作用。


我正在使用 Tomcat for Visual Studio Code 扩展 v.0.11.1。


我的 tasks.json 看起来像这样:


{

    // See https://go.microsoft.com/fwlink/?LinkId=733558

    // for the documentation about the tasks.json format

    "version": "2.0.0",

    "tasks": [

        {

            "label": "Build",

            "type": "shell",

            "command": "gradlew clean build",

            "group": {

                "kind": "build",

                "isDefault": true

            }

        },

        {

            "label": "Deploy",

            "type": "shell",

            "command": "adashen.vscode-tomcat:tomcat.war.run",

            "args": ["${workspaceFolder}\\build\\libs\\SMEWeb-0.0.1-SNAPSHOT.war"]

        }

    ]

}

执行后得到以下错误:


在文件夹 SMEWeb 中执行任务:adashen.vscode-tomcat:tomcat.war.run C:\WorkspaceGit\sme\SMEWeb\build\libs\SMEWeb-0.0.1-SNAPSHOT.war <


文件名、目录名或卷标语法不正确。


终端进程命令 'C:\Windows\system32\cmd.exe /d /c adashen.vscode-tomcat:tomcat.war.run C:\WorkspaceGit\sme\SMEWeb\build\libs\SMEWeb-0.0.1-SNAPSHOT .war' 启动失败(退出代码:1)


终端将被任务重用,按任意键关闭它。


有人有线索吗?谢谢


慕容708150
浏览 253回答 3
3回答

慕慕森

阅读源代码后,我认为如果该方法接受文件路径作为字符串或者如果您设法将“vscode.Uri”对象作为参数传递给“tomcat.war.run”命令,它可能会起作用。这是我在整个过程中所能想到的最好的结果,但是每次运行此任务时您仍然必须手动选择 .war:{&nbsp; &nbsp; "version": "2.0.0",&nbsp; &nbsp; "tasks": [&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "label": "compile",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "type": "shell",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "command": "mvn compile",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "problemMatcher": []&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "label": "package",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "type": "shell",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "command": "mvn package",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "dependsOn": ["compile"],&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "problemMatcher": []&nbsp; &nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "label": "Run WAR",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "command": "${input:runWar}",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "dependsOn": ["package"],&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "problemMatcher": []&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; ],&nbsp; &nbsp; "inputs": [&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "id": "runWar",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "type": "command",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "command": "tomcat.war.run"//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ,"args": { DOESNT WORK =///&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "uri" : {"fsPath" : "${workspaceFolder}/target/ROOT.war"}//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; ]}

Helenr

它可能看起来像这样。&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; "label": "Run",&nbsp; &nbsp; &nbsp; &nbsp; "command": "${command:tomcat.war.run}",&nbsp; &nbsp; &nbsp; &nbsp; "problemMatcher": []&nbsp; &nbsp; }经过大量搜索我自己的用途后,我从这里得到了帮助:https ://stackoverflow.com/a/57470981/4588923我还没有找到一种方法来提供 .war 文件作为参数并且它有效。虽然调用来自 tasks.json,但我认为主要问题是扩展不支持这样做。也许功能请求是有序的。

鸿蒙传说

RedHat 开发了一个 VSCode 扩展,有助于在 VSCode 中配置和部署 tomcat 服务器。似乎比我尝试过的其他人要好得多。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java