简体   繁体   English

如何在不删除/取消部署旧应用程序的情况下在tomcat中重新部署war文件?

[英]How to redeploy war file in tomcat without deleting/undeploy the old application?

I already have a working Tomcat Server with Web Manager where I can deploy my WAR file. 我已经有一个带有Web Manager的Tomcat服务器,我可以部署我的WAR文件。

The WAR file contains my web application and this web application has a feature where user can upload images into one of it's folder. WAR文件包含我的Web应用程序,此Web应用程序具有一个功能,用户可以将图像上载到其中一个文件夹中。

The problem is when I need to update the web application using a new WAR file. 问题是当我需要使用新的WAR文件更新Web应用程序时。

When I upload it through Tomcat manager. 当我通过Tomcat管理器上传它。 It says WAR file already exist. 它说WAR文件已经存在。 I have to UNDEPLOY it first before I can upload the updated WAR. 在我上传更新的WAR之前,我必须首先取消它。

I don't want to do this UNDEPLOY process because it will delete the application along with all the images that user already uploaded. 我不想执行此UNDEPLOY过程,因为它将删除应用程序以及用户已上载的所有图像。

So, how can I update my web application without deleting those uploaded files? 那么,如何在不删除上传文件的情况下更新我的Web应用程序? Or maybe I was using the wrong approach with my application? 或者我的应用程序使用了错误的方法?

Since I need a quick fix. 因为我需要快速修复。 Here is what I did to make it work: 这是我做的工作:

  1. Create a temporary folder anywhere on the server lets say "/var/tmp/war_images". 在服务器上的任何位置创建一个临时文件夹,让我们说“/ var / tmp / war_images”。 This will be used to temporarily store uploaded images when deploying a new war 这将用于在部署新战争时临时存储上传的图像
  2. Create a folder to put new WAR file. 创建一个文件夹以放置新的WAR文件。 lets say "/var/tmp/war" 让我们说“/ var / tmp / war”
  3. Create a shell script that do these things: 创建一个执行以下操作的shell脚本:
    • Copy all images from folder where user upload their images to the temp folder above 将用户上传图像的文件夹中的所有图像复制到上面的临时文件夹中
    • Delete application folder in tomcat 删除tomcat中的应用程序文件夹
    • Delete WAR file in tomcat 删除tomcat中的WAR文件
    • Copy new WAR file from point 2 to tomcat8 folder 将新WAR文件从第2点复制到tomcat8文件夹
    • Restart tomcat (to trigger the deployment) 重启tomcat(触发部署)
    • Copy back all images from point no.1 back to app folder newly created by the deployment process 将第1点的所有图像复制回部署过程新创建的应用程序文件夹

So when I want to deploy a new WAR. 所以,当我想部署一个新的WAR时。 I put the new WAR file on step no.2 and then execute the shell script. 我将新的WAR文件放在第2步,然后执行shell脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过删除jboss中的文件来取消部署战争 - Undeploy war by deleting file in jboss 如何无缝地在Tomcat中重新部署战争? - How to redeploy a war in tomcat seamlessly? 如何配置tomcat每次重新部署战争? - How to configure tomcat to redeploy war every time? 如何在不影响Tomcat的情况下替换已编译jar中的文件 - How to replace file in compiled jar without affectig Tomcat redeploy 重新部署战争时是否需要重新启动tomcat? - Is it necessary to restart tomcat when redeploy a war? 重新部署tomcat Live生产服务器的战争 - Redeploy war on tomcat live productive server 如何使用maven-tomcat7-plugin在Tomcat上适当地热部署/重新部署战争? - How to properly hot deploy/redeploy war on Tomcat with maven-tomcat7-plugin? 防止tomcat 7在我的webapp的每次覆盖/取消部署时删除我的自定义上下文文件 - prevent tomcat 7 from deleting my custom context file on every single overwrite/undeploy of my webapp 如何在云上使用tomcat 8运行java应用程序(war文件)? 在哪里? - How to run java application(war file) using tomcat 8 on cloud? & Where? 如何在Spring Boot应用程序中启用HTTPS,该应用程序在Tomcat中作为WAR文件部署? - How to enable HTTPS in a Spring Boot application, deployed as WAR file in Tomcat?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM