tomcat中发布的项目A,默认只能通过http://ip:port/A/来访问项目,也就是需要在访问路径上添加项目名字。如果不想添加项目名字,这就需要将项目解压到tomcat的webapp/ROOT/目录下,默认tomcat的ROOT目录下的工程就是根目录。如何把A目录映射到根目录?
在conf/server.xml中,添加context
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Context path="" docBase="/path/to/A.war" debug="0" reloadable="true"/>
</Host>
再将webapp目录中的ROOT整个目录删除掉。
这个时间再启动就可以直接通过http://ip:port/来访问A项目。
这个方案目录前一个缺点:jenkins发布时不能成功。
- Context / is defined in server.xml and may not be undeployed
org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: FAIL - Context / is defined in server.xml and may not be undeployed
从错误看根/ 不能重新发布。