Tomcat 7 到 war 文件的符号链接 [英] Tomcat 7 symbolic link to war file

查看:30
本文介绍了Tomcat 7 到 war 文件的符号链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在 tomcat 的 webapps 目录中有一个符号链接,它指向我文件系统中另一个位置的一个 war 文件,并且我希望该 war 文件用作默认的 webapp.我拼凑了以下解决方案,但无法从浏览器访问该应用.

I would like to have a symbolic link in tomcat's webapps directory that points to a war file at another place in my file system, and I would like that war file to be served as the default webapp. I have pieced together the following solution, but the app is not accessible from the browser.

我的主目录中有一个文件夹 ~/tomcat/webapps.楼主是tomcat7.在这个文件夹中,我有我的 war 文件 myapp-1.0.war.

I have a folder in my home directory ~/tomcat/webapps. The owner is tomcat7. In this folder, I have my war file, myapp-1.0.war.

在我的/var/lib/tomcat7/webapps 目录中,我有一个符号链接:

In my /var/lib/tomcat7/webapps directory, I have a symbolic link:

myapp -> /home/[me]/tomcat/webapps/myapp-1.0.war.

在我的/etc/tomcat7/server.xml 中,我有:

In my /etc/tomcat7/server.xml, I have:

<Context docBase="/var/lib/tomcat7/webapps/myapp" path="" reloadable="true" allowLinking="true"/>

Tomcat 开始时日志中没有任何抱怨,但我的应用程序无法访问.[host]:8080/rest/返回 404,通常会带我到主页.

Tomcat starts with no complaints in the logs, but my app is not accessible. [host]:8080/rest/ returns 404, where it would normally take me to the home page.

我部分想这样做是为了从我的战争文件中提取版本号.任何想法为什么这不起作用,或者我做错了什么?

I partially want to do this to abstract out the version number from my war file. Any ideas why this is not working, or what I'm doing wrong?

谢谢.

推荐答案

我发现了问题.webapps 目录中的符号链接需要具有 .war 扩展名.所以,而不是:

I found the problem. The symlink in the webapps directory needs to have a .war extension. So, instead of:

myapp -> /home/[me]/tomcat/webapps/myapp-1.0.war

应该是:

myapp.war -> /home/[me]/tomcat/webapps/myapp-1.0.war

我还可以缩短 docBase 属性的值,如下所示:

I was also able to shorten the value of the docBase attribute as below:

<Context docBase="myapp" path="" reloadable="true" allowLinking="true"/>

这篇关于Tomcat 7 到 war 文件的符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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