Java Web应用程序应该在哪里存储其数据? [英] Where should a Java web application store its data?

查看:503
本文介绍了Java Web应用程序应该在哪里存储其数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Java Web应用程序( myapp.war )是通过将它放在Tomcat上的 webapps 目录中来部署的Ubuntu 10.04。

My Java web application (myapp.war) ist deployed by placing it into the webapps direcotry on Tomcat on Ubuntu 10.04.

此应用程序需要在文件中保存一些数据。但是运行Tomcat( tomcat6 )的用户对主目录没有写访问权限 / usr / share / tomcat6 / 并且没有对当前工作目录 / var / lib / tomcat6 / 的写访问权限,因为它们都属于 root

This application needs to save some data in files. But the user, which is running Tomcat (tomcat6) has no write access to the home directory /usr/share/tomcat6/ and no write access to the current working direcotry /var/lib/tomcat6/, since both belong to root.

那么Web应用程序应该在哪里存储其数据?我希望它不是webapps direcotry中提取的存档。这个可以很容易地被删除。并且可以配置Tomcat,而不是提取.war文件。然后就没有提取的目标。

So where should a web application store its data? I hope it is not the extracted archive in the webapps direcotry. This one could be deleted very easily by accident. And Tomcat can be configured, not to extract .war files. Then there would be no extracted direcotry.

或许 / var / lib / tomcat6 / 应该属于用户 tomcat6 ant这是Ubuntu中的一个错误?

Perhaps /var/lib/tomcat6/ should belong to user tomcat6 ant this is a bug in Ubuntu?

推荐答案

我找到了解决方法发射台。 / var / lib / tomcat6 / webapps / 是可写的。这意味着,以下工作:

I found the solution on Launchpad. /var/lib/tomcat6/webapps/ is writable. This means, that the following works:

File myFile = new File("webapps/myfile.txt");

这篇关于Java Web应用程序应该在哪里存储其数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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