在哪里/如何使用tomcat存储持久数据? [英] Where/how to store persistent data with tomcat?

查看:116
本文介绍了在哪里/如何使用tomcat存储持久数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该在Tomcat Web应用程序中将持久性文件存储在哪里?

Where should I store persistent files in a Tomcat web app ?


  • javax.servlet.context.tempdir不可行,它已被删除重新部署/删除应用程序时

  • 不想在例如使用绝对路径servlet init参数

  • 将文件存储在数据库中不是一个选项

推荐答案

我们的团队做了很多。我们遵循的一般规则是在Web应用程序之外和Tomcat之外。

Our team does this a lot. A general rule we follow is outside the web app and outside Tomcat.

我们的sysadmin在我们的服务器上设置一个tomcat用户具有rw权限的目录(例如的/ var / Tomcat的/持续)。我们在这下构建了一个目录结构,tomcat用它来存储文件,读取特定于应用程序的init文件等。

Our sysadmin set up a directory on our server that the tomcat user has rw permissions to (e.g. /var/tomcat/persist). We have a built a directory structure under this that tomcat uses to store files, read app-specific init files, etc.

如果你不想使用绝对的你的servlet的init-params中的路径,考虑在启动tomcat时设置系统属性。好消息是在tomcat下运行的每个应用程序都可以访问它。糟糕的是,在tomcat下运行的每个应用程序都可以访问它。您可以设置名为 base.persist.dir 的属性,并为其下的每个应用程序构建子目录。我们在CATALINA_OPTS环境变量下的 bin / 目录中的 setenv.sh 脚本中设置系统属性。

If you don't want to use an absolute path in your init-params for your servlet, consider setting a system property when tomcat is started up. The good thing about that is every application running under tomcat will have access to it. The bad thing about that is every application running under tomcat will have access to it. You could set a property named base.persist.dir and build subdirectories for each application underneath it. We set system properties in the setenv.sh script in the bin/ directory under the CATALINA_OPTS environment variable.

这篇关于在哪里/如何使用tomcat存储持久数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆