问题描述
Tomcat
配置多个端口启动多个项目
解决方案:
在Tomcat
的 server.xml
添加如下配置
<!-- 注意 port 和 redirectPort一定不能重复 -->
<Service name="Catalina">
<!-- http端口、协议、超时时间、https端口配置 -->
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
</Realm>
<!-- 设置appBase文件夹为webapps -->
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
<!-- 日志生成文件夹、文件前缀、文件后缀配置 -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
<!--1.9000 port="9000",appBase="webapps1"-->
<Service name="Catalina">
<!-- http端口、协议、超时时间、https端口配置 -->
<Connector port="9000" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8444" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
</Realm>
<!-- 设置appBase文件夹为webapps1 -->
<Host name="localhost" appBase="webapps1" unpackWARs="true" autoDeploy="true">
<!-- 日志生成文件夹、文件前缀、文件后缀配置 -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>