如何同时启动多个Tomcat服务
在项目开发中,有时会需要同时启动多个Tomcat服务,如果直接启动多个的话,会报以下错误:
Port busy xxxx java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind,
这个就是端口被占用了,所以我们需要做的事就是改端口,首先到tomcat的conf文件夹下找到server.xml配置文件,需要改三个地方的端口:
1.修改http访问端口(默认为8080端口),比如改为8888
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector" port="8080" minProcessors="5" maxProcessors="75" enableLookups="true" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" useURIValidationHack="false" disableUploadTimeout="true" />
2. 修改Shutdown端口(默认为8005端口),比如改为8006
<Server port="8005" shutdown="SHUTDOWN" debug="0">
3.修改JVM启动端口(默认为8009端口),比如改为8019
< Connector className ="org.apache.coyote.tomcat4.CoyoteConnector" port ="8009" minProcessors ="5" maxProcessors ="75" enableLookups ="true" redirectPort ="8443" acceptCount ="10" debug ="0" connectionTimeout ="20000" useURIValidationHack ="false" protocolHandlerClassName ="org.apache.jk.server.JkCoyoteHandler" />
到此完成配置修改,重启Tomcat,ok。