Tomcat9 多端口 多项目
程序员文章站
2024-03-25 14:04:58
...
1.修改../tomcat/conf/server.xml,原有代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina80">
<Executor name="tomcatThreadPool80" namePrefix="catalina-exec-" maxThreads="1000" maxIdleTime="60000" minSpareThreads="20"/>
<Connector port="80" protocol="org.apache.coyote.http11.Http11AprProtocol"
executor="tomcatThreadPool80" compression="on" compressionMinSize="2048" noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain,application/json,application/x-javascript"
maxThreads="30000" minSpareThreads="512" enableLookups="false" acceptCount="35000"
connectionTimeout="40000" disableUploadTimeout="true" URIEncoding="UTF-8" useBodyEncodingForURI="true" redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina80" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps80" unpackWARs="true" autoDeploy="true">
</Host>
</Engine>
</Service>
<Service name="Catalina81">
<Executor name="tomcatThreadPool81" namePrefix="catalina-exec-" maxThreads="1000" maxIdleTime="60000" minSpareThreads="20"/>
<Connector port="81" protocol="org.apache.coyote.http11.Http11AprProtocol"
executor="tomcatThreadPool81" compression="on" compressionMinSize="2048" noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain,application/json,application/x-javascript"
maxThreads="30000" minSpareThreads="512" enableLookups="false" acceptCount="35000"
connectionTimeout="40000" disableUploadTimeout="true" URIEncoding="UTF-8" useBodyEncodingForURI="true" redirectPort="8443" />
<Connector port="8019" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina81" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps81" unpackWARs="true" autoDeploy="true">
</Host>
</Engine>
</Service>
<Service name="Catalina82">
<Executor name="tomcatThreadPool82" namePrefix="catalina-exec-" maxThreads="1000" maxIdleTime="60000" minSpareThreads="20"/>
<Connector port="82" protocol="org.apache.coyote.http11.Http11AprProtocol"
executor="tomcatThreadPool82" compression="on" compressionMinSize="2048" noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain,application/json,application/x-javascript"
maxThreads="30000" minSpareThreads="512" enableLookups="false" acceptCount="35000"
connectionTimeout="40000" disableUploadTimeout="true" URIEncoding="UTF-8" useBodyEncodingForURI="true" redirectPort="8443" />
<Connector port="8029" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina82" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps82" unpackWARs="true" autoDeploy="true">
</Host>
</Engine>
</Service>
<Service name="Catalina83">
<Executor name="tomcatThreadPool83" namePrefix="catalina-exec-" maxThreads="1000" maxIdleTime="60000" minSpareThreads="20"/>
<Connector port="83" protocol="org.apache.coyote.http11.Http11AprProtocol"
executor="tomcatThreadPool83" compression="on" compressionMinSize="2048" noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain,application/json,application/x-javascript"
maxThreads="30000" minSpareThreads="512" enableLookups="false" acceptCount="35000"
connectionTimeout="40000" disableUploadTimeout="true" URIEncoding="UTF-8" useBodyEncodingForURI="true" redirectPort="8443" />
<Connector port="8039" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina83" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps83" unpackWARs="true" autoDeploy="true">
</Host>
</Engine>
</Service>
</Server>
2、创建目录 a. 创建需要部署的目录
../Tomcat9/webapps80/ROOT,../Tomcat9/webapps81/ROOT,../Tomcat9/webapps82/ROOT,../Tomcat9/webapps83/ROOT,并将需要部署的项目拷贝至该目录ROOT下;
b. 创建配置文件目录
../Tomcat/conf/Catalina80/localhost,../Tomcat/conf/Catalina81/localhost,../Tomcat/conf/Catalina82/localhost,../Tomcat/conf/Catalina83/localhost
3.修改项目代码 在我尝试的过程中发现一个比较容易出错的地方,就是最好修改web.xml和log4j.properties配置文件。 其中web.xml文件,需要添加webAppRootKey,代码如下:
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>app1.root</param-value>
</context-param>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>app2.root</param-value>
</context-param>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>app3.root</param-value>
</context-param>
即可完工。``` 这里输入代码
转载于:https://my.oschina.net/glenxu/blog/806583
上一篇: 文件操作
下一篇: docker 之 rabbitmq
推荐阅读
-
Tomcat9 多端口 多项目
-
maven 企业级多模块项目 博客分类: 开发(版本)环境工具 maven
-
spring项目配置多环境配置文件
-
如何实现双(多)语种网站内容的国际化? 博客分类: Work Related 数据结构CMS企业应用配置管理项目管理
-
详解IDEA多module项目maven依赖的一些说明
-
如何使用eclipse搭建maven多module项目(构建父子项目)
-
SpringBoot创建maven多模块项目实战代码
-
详解使用Maven构建多模块项目(图文)
-
IntelliJ IDEA创建maven多模块项目(图文教程)
-
如何使用eclipse搭建maven多module项目(构建父子项目)