如何用tomcat设置多个端口
如何用tomcat设置多个端口,使每个程序分别对应不同的端口 比如http://localhost:8080 的时候访问 project1; 比如http://localhost:8085 的时候访问 project2; 比如http://localhost:8086 的时候访问 project3
[最优解释]
server.xml默认的
<Service name="Catalina">
<Connector port="8080" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
<Connector port="8009"
enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context docBase="project1.war" path="/project1" auth="Container">
<Resource
name="testDb"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
maxIdle="2"
maxWait="5000"
username="1234"
password="1234"
url="jdbc:oracle:thin:@127.0.0.1:1521:testora"
maxActive="4"/>
</Context>
</Host>
</Engine>
</Service>
你自己添加一个:
<Service name="tttttt">
<Connector port="8088" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8448" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
<Connector port="8089"
enableLookups="false" redirectPort="8448" protocol="AJP/1.3" />
<Engine name="tttttt" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context docBase="project2.war" path="/project2" auth="Container">
<Resource
name="testdddd"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
maxIdle="2"
maxWait="5000"
username="1234"
password="1234"
url="jdbc:oracle:thin:@127.0.0.1:1521:testtttt"
maxActive="4"/>
</Context>
</Host>
</Engine>
</Service>
[其他解释]
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8081" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Context path="/service" docBase="D:\zxhyworkspace\service\WebRoot" debug="0" reloadable="false" />