Tomcat 偶尔会自行重新部署 WAR 吗?
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Tomcat 就会自动部署而无需重新启动
只要您在
/conf/server.xml
中编辑了扩展 WAR 中的资源之一, 。但实际上并不建议在生产环境中使用此设置,因为它可能会导致内存泄漏。默认情况下此功能也是关闭的。也就是说,我强烈建议将您正在谈论的数据放在 WAR 之外。如果它们应该是 web 应用程序运行时类路径的一部分,只需将它们放在 Tomcat 外部的固定磁盘文件系统路径中,例如
/var/webapp/config
并编辑shared.loader<
/conf/catalina.properties
的 /code> 属性来指定该路径:然后这些资源将以通常的方式在类路径中可用。这样您就不需要备份并重新添加它,这非常笨拙并且很容易出错。
Tomcat will only autodeploy without restart whenever you have
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 theshared.loader
property of/conf/catalina.properties
to specify that path: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.