Tomcat 偶尔会自行重新部署 WAR 吗?

发布于 2024-12-10 02:13:04 字数 236 浏览 0 评论 0原文

我有一个 Web 应用程序,它作为 WAR 文件部署到 Tomcat 6 服务器。它将一些数据存储在应用程序本身内部的目录中。部署新版本的应用程序时,这些文件会被覆盖,但备份并重新添加它们很简单。

然而,我的一位同事声称 Tomcat 有时会自发地重新分解我的 WAR 文件,即使分解的版本已经存在,并清除这些文件。我以前从未见过这种行为。如果确实有必要的话,我可以找到解决方法,但这是否是实际发生的事情,无论是自发的还是在服务器重新启动时?

I have a webapp that is deployed as a WAR file to a Tomcat 6 server. It stores some data in a directory inside the app itself. These files get overwritten when a new version of the app is deployed, but it's trivial to back them up and re-add them.

However, one of my coworkers claims that Tomcat will sometimes spontaneously re-explode my WAR file, even if the exploded version is already there, and wipe out these files. I have never seen this behavior before. I can figure out a workaround for this if I really have to, but is this something that actually happens, either spontaneously or on server restart?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一抹淡然 2024-12-17 02:13:04

Tomcat 就会自动部署而无需重新启动

<Host autoDeploy="true">

只要您在 /conf/server.xml 中编辑了扩展 WAR 中的资源之一, 。但实际上并不建议在生产环境中使用此设置,因为它可能会导致内存泄漏。默认情况下此功能也是关闭的。

也就是说,我强烈建议将您正在谈论的数据放在 WAR 之外。如果它们应该是 web 应用程序运行时类路径的一部分,只需将它们放在 Tomcat 外部的固定磁盘文件系统路径中,例如 /var/webapp/config 并编辑 shared.loader< /conf/catalina.properties 的 /code> 属性来指定该路径:

shared.loader = /var/webapp/config

然后这些资源将以通常的方式在类路径中可用。这样您就不需要备份并重新添加它,这非常笨拙并且很容易出错。

Tomcat will only autodeploy without restart whenever you have

<Host autoDeploy="true">

in your /conf/server.xml and you edit one of the resources in the expanded WAR. But this setting is not really recommended for production environments as it may lead to memory leaks. This is also by default turned off.

That said, I strongly recommend to put that data you're talking about outside the WAR. If they are supposed to be part of the webapp's runtime classpath, just put them in a fixed disk file system path outside Tomcat, e.g. /var/webapp/config and edit the shared.loader property of /conf/catalina.properties to specify that path:

shared.loader = /var/webapp/config

Those resources will then be available in the classpath the usual way. This way you don't need to backup and re-add it, which is plain clumsy and very error prone.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文