从配置文件创建war文件

发布于 2024-11-02 15:23:46 字数 488 浏览 5 评论 0原文

在当前的系统设置中,我有几个配置文件存储在conf/Catalina/localhost 目录中。例如 images.xml:

<Context path="/images" docBase="/home/user/images" debug="0" privileged="true" />

这允许链接到此目录内的文件,例如: http://localhost: 8080/images/image.jpg

但是,当映射的驱动器位于网络位置时,与驱动器的连接会丢失。由于 Tomcat 随后无法到达目标,因此配置会自动取消部署。由于真正的 Web 应用程序在此服务器上运行,我不想更改此 Tomcat 设置。

那么问题是,我可以将此配置包含在 WAR 文件中吗?这将使重新部署变得更容易,并且可能允许我捆绑配置?

In the current system set up I have several configuration files stored in the conf/Catalina/localhost directory. For example images.xml:

<Context path="/images" docBase="/home/user/images" debug="0" privileged="true" />

This allows to link to files inside this directory, for example: http://localhost:8080/images/image.jpg

But when the mapped drive is on a network location it happens that the connection to the drive is lost. Because Tomcat is then unable to reach the destination the configuration is automatically undeployed. Because of the real web application running on this server I don't want to change this Tomcat settings.

So the question is, can I include this configuration in a WAR file? This would make it easier to redeploy and probably allow me to bundle configurations?

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

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

发布评论

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

评论(2

莫言歌 2024-11-09 15:23:46

具体配置告诉 tomcat 从指定目录(tomcat 默认目录之外)加载 Web 应用程序。这是 tomcat 特定的配置,因此即使可以在战争中捆绑此配置(我认为你不能),我建议不要走这条路。

更好的方法是将图像作为展开的 war 文件捆绑到您的图像中(以便您可以在 tomcat 运行时添加删除图像)并将其部署在 tomcat 中。据我了解,您希望将图像保存在连接间歇性的单独网络驱动器中。在这种情况下,当资源不可用时,tomcat 取消部署上下文是有意义的。

The specific configuration tells tomcat to load the web app from a specified directory (outside of tomcat's default). This is tomcat specific configuration so even if it was possible to bundle this config in war (which i don't think you can) I'd recommend not to go that path.

The better way would be bundle to your images as a exploded war file (so that you can add remove images while tomcat is running)and deploy it in the tomcat. As i understand you want to keep you images in separate network drive whose connectivity is intermittent. In that case it makes sense for tomcat to undeploy the context when the resource is not available.

划一舟意中人 2024-11-09 15:23:46

如果您创建一个名为 images.war 的 war 文件并将其放在 webapps/ROOT 目录中,那么它将自动映射到上下文路径 images (基于 war 文件)姓名)。所以你可以这样做。
确保还包含部署描述符 (web.xml) - 详细信息如下:http://download.oracle.com/docs/cd/E13222_01/wls/docs81/webapp/web_xml.html

抱歉,您的评论很准确 - - 我不注意就活该! 它确实是 webapps 目录,而不是我上面复制和粘贴的 webapps/ROOT。

if you create a war file called images.war and place it in your webapps/ROOT directory then this will automatically be mapped onto the context path images (based on the war file name). So you can do it this way.
Make sure you also include a deployment descriptor (web.xml) -- details here: http://download.oracle.com/docs/cd/E13222_01/wls/docs81/webapp/web_xml.html

Sorry you are spot on with your comment -- serves me right for not paying attention! It is indeed the webapps directory and not webapps/ROOT as I copied and pasted above.

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