我必须在tomcat 7中部署我的app.war文件.war文件名之后是版本号 . 在这里,我需要设置一个上下文路径,以便实际的url只包含应用程序名称(没有版本号) .
我的要求是,server.xml中不应该编辑 .
我的context.xml如下 .
<?xml version='1.0' encoding='utf-8'?>
<Context path="/app" docBase="app-1.0" debug="0" reloadable="true">
<!-- Defines links to JNDI Data Sources -->
<!-- Thus the server determines database connection. -->
<ResourceLink
name="..."
global="..."
auth="Container" type="javax.sql.DataSource"/>
.....
.....
</Context>
context.xml放在/ META-INF文件夹的war内 . 谁能告诉我我哪里错了 .
2 回答
所有元素都在文档中:http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Naming
对于您的用例,您可以尝试:
更改您的版本号格式(例如,从app-1.0.0.war到app ## 1.0.0.war)
将你的战争放在另一个文件夹中并在
$catalina.base/conf/Catalina/
中创建一个app.xml,其中包含:<Context path="/app" docBase="/path/to/app-1.0" debug="0" reloadable="true">
避免与版本号进行战争
有类似的问题,我花了很长时间才找到解决方案 . 它位于tomcat网站上,但很难找到 . 这就是我做的 .
您的war文件将部署到%CATALINA_BASE%下的文件夹中 . 我把我放在一个名为deploy的文件夹中 . (%CATALINA_BASE%/部署)
您'll create an XML file with the path to your war file above and place it in %CATALINA_BASE%/conf/Catalina/localhost. The name of the xml file will become your context root. If the name of your war file is app1.2.war and you want your context root to be /app you'重新创建app.xml:
<?xml version='1.0' encoding='utf-8'?> <Context docBase="C:\tomcat7\Servers\server-app\deploy\app1.2" reloadable="false"/>
(我的部署在Windows上,您显然必须针对不同的操作系统进行调整 . )另外,无论出于何种原因,我们都希望您的上下文根目录为/ foo / Bar / app,将xml的名称更改为foo#Bar#app.xml .