将项目打成war包,放入webapp目录下,修改conf目录下server.xml
修改host内容
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
改为
<Host name="localhost" appBase="" unpackWARs="true" autoDeploy="true">
<Context docBase="webapps/你的项目名" path="" reloadable="true" source="org.eclipse.jst.jee.server:你的项目名"/>
如下图所示,改之前
改之后
此时运行tomcat,可以不需要项目路径访问项目,也就是说访问 http://localhost:8080就行了
但是弊端也很明显,只能配置一个项目