在server.xml中配置两个service为Catalina.app1和Catalina.app2
<Service name="Catalina.app1"> <Connector connectionTimeout="20000" port="8081" protocol="HTTP/1.1" redirectPort="8443"/> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/> <Engine defaultHost="localhost" name="Catalina.app1"> <Realm className="org.apache.catalina.realm.LockOutRealm"> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </Realm> <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true"> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log." suffix=".txt"/> <Context docBase="D:\Program Files\apache-tomcat-7.0.62\webapps\test" path="" reloadable="true" source="org.eclipse.jst.jee.server:test"/></Host> </Engine> </Service> <Service name="Catalina.app2"> <Connector connectionTimeout="20000" port="8082" protocol="HTTP/1.1" redirectPort="8443"/> <Connector port="8010" protocol="AJP/1.3" redirectPort="8443"/> <Engine defaultHost="localhost" name="Catalina.app2"> <Realm className="org.apache.catalina.realm.LockOutRealm"> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </Realm> <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true"> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log." suffix=".txt"/> <Context docBase="D:\Program Files\apache-tomcat-7.0.62\webapps\springmvc_hello" path="/springmvc_hello" reloadable="true" source="org.eclipse.jst.jee.server:springmvc_hello"/></Host> </Engine> </Service>
配置后启动tomcat
参考文章:
http://www.linuxidc.com/Linux/2012-06/62032p2.htm
本文出自 “点滴积累” 博客,请务必保留此出处http://tianxingzhe.blog.51cto.com/3390077/1704006