因此,我目前正在为我的简单java webapp使用VS代码,但我发现这有点繁琐,因为每次对项目本身进行更改时,我都必须部署一个.war文件。
完整的程序如下:
运行模式war:war
这个过程大约需要3-5秒,这并不是最好的,因为每个开发人员都会不断地测试/调试/更新他们的代码。
我在VS代码中用于部署Tomcat服务器的当前扩展是。
我想知道是否有办法将web应用程序与对项目本身所做的更改完全同步。
发布于 2022-11-22 08:14:20
您可以使用扩展。

下面是一个简单的maven项目作为示例。

compile项目在MAVEN面板中的应用

下载扩展后,在settings.json.中添加以下配置
"deploy": {
"packages": [
{
"name": "frontend",
"description": "All files in webapp",
"files": [
"src/main/webapp/*",
"src/main/webapp/*/*",
"src/main/webapp/*.*",
"src/main/webapp/*/*.*",
"src/main/webapp/*/*/*.*",
"src/main/webapp/*/*/*/*.*",
"src/main/webapp/*/*/*/*/*.*",
"src/main/webapp/*/*/*/*/*",
"src/main/webapp/*/*/*/*/*/*.*",
],
"exclude": [
"src/main/webapp/test/*"
],
"deployOnSave": true,
"useTargetList": true,
"button": {
"text": "Deploy",
"tooltip": "Click here to deploy frontend to hotsite",
"targets": [ "HOTSITE" ]
},
}
],
"targets": [
{
"type": "local",
"name": "HOTSITE",
"description": "A local folder",
"dir": "target/DETE/",
"mappings": [
{
"source": "src/main/webapp",
"isRegEx": false,
"target": "/"
}
]
}
]
}添加完成后,单击下面状态栏中出现的Deploy按钮。

右键单击tomcat服务器并选择Add Deployment。

下一步选择Exploded

选择只通过单击资源管理器中的文件夹生成的Deploy

在浏览器地址栏中键入http://localhost:8080/DETE并按Enter键

或右键单击tomcat并选择Server Actions... -> Show in Browser... -> http://localhost:8080/DETE
修改.jsp以添加一行内容

刷新页面显示已更改的内容。

https://stackoverflow.com/questions/74520275
复制相似问题