MyEclipse配置多个tomcat - 全栈笔记

MyEclipse配置多个tomcat

任亦伟 JAVA 2015-04-01 189 次浏览 没有评论

机子上MyEclipse上面配置的tomcat添加了许多个项目,导致修改一个项目后重启tomcat需要浪费许多时间去等待,所以为MyEclipse配置了多个tomcat,以便缩减tomcat的启动时间。

方法有两种,第一种简单一些,复制粘贴出多个tomcat,具体方法如下:

1、复制粘贴出一个tomcat

copy_tomcat

2、进入conf/server.xml配置文件进行如下修改:

①修改shutdown监听端口

1
2
<!--这个8005修改成8015 不要重复就好了,修改成8006也可以的-->
3
<Server port="8005" shutdown="SHUTDOWN">
4

②修改http监听端口

1
2
    <!--修改http监听端口8080为8081 不冲突即可-->
3
    <Connector port="8080" protocol="HTTP/1.1"
4
               connectionTimeout="20000"
5
               redirectPort="8443" />
6

③修改ajp监听端口,我们一般通过http方式请求,所以,下面这一行直接注释即可

1
2
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
3

④修改后的server.xml

001
<?xml version='1.0' encoding='utf-8'?>
002
<!--
003
  Licensed to the Apache Software Foundation (ASF) under one or more
004
  contributor license agreements.  See the NOTICE file distributed with
005
  this work for additional information regarding copyright ownership.
006
  The ASF licenses this file to You under the Apache License, Version 2.0
007
  (the "License"); you may not use this file except in compliance with
008
  the License.  You may obtain a copy of the License at
009
 
010
      http://www.apache.org/licenses/LICENSE-2.0
011
 
012
  Unless required by applicable law or agreed to in writing, software
013
  distributed under the License is distributed on an "AS IS" BASIS,
014
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015
  See the License for the specific language governing permissions and
016
  limitations under the License.
017
-->
018
<!-- Note:  A "Server" is not itself a "Container", so you may not
019
     define subcomponents such as "Valves" at this level.
020
     Documentation at /docs/config/server.html
021
 -->
022
<Server port="8015" shutdown="SHUTDOWN">
023
  <!-- Security listener. Documentation at /docs/config/listeners.html
024
  <Listener className="org.apache.catalina.security.SecurityListener" />
025
  -->
026
  <!--APR library loader. Documentation at /docs/apr.html -->
027
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
028
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
029
  <Listener className="org.apache.catalina.core.JasperListener" />
030
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
031
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
032
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
033
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
034
 
035
  <!-- Global JNDI resources
036
       Documentation at /docs/jndi-resources-howto.html
037
  -->
038
  <GlobalNamingResources>
039
    <!-- Editable user database that can also be used by
040
         UserDatabaseRealm to authenticate users
041
    -->
042
    <Resource name="UserDatabase" auth="Container"
043
              type="org.apache.catalina.UserDatabase"
044
              description="User database that can be updated and saved"
045
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
046
              pathname="conf/tomcat-users.xml" />
047
  </GlobalNamingResources>
048
 
049
  <!-- A "Service" is a collection of one or more "Connectors" that share
050
       a single "Container" Note:  A "Service" is not itself a "Container",
051
       so you may not define subcomponents such as "Valves" at this level.
052
       Documentation at /docs/config/service.html
053
   -->
054
  <Service name="Catalina">
055
 
056
    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
057
    <!--
058
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
059
        maxThreads="150" minSpareThreads="4"/>
060
    -->
061
 
062
 
063
    <!-- A "Connector" represents an endpoint by which requests are received
064
         and responses are returned. Documentation at :
065
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
066
         Java AJP  Connector: /docs/config/ajp.html
067
         APR (HTTP/AJP) Connector: /docs/apr.html
068
         Define a non-SSL HTTP/1.1 Connector on port 8080
069
    -->
070
    <Connector port="8081" protocol="HTTP/1.1"
071
               connectionTimeout="20000"
072
               redirectPort="8443" />
073
    <!-- A "Connector" using the shared thread pool-->
074
    <!--
075
    <Connector executor="tomcatThreadPool"
076
               port="8080" protocol="HTTP/1.1"
077
               connectionTimeout="20000"
078
               redirectPort="8443" />
079
    -->
080
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
081
         This connector uses the BIO implementation that requires the JSSE
082
         style configuration. When using the APR/native implementation, the
083
         OpenSSL style configuration is required as described in the APR/native
084
         documentation -->
085
    <!--
086
    <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
087
               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
088
               clientAuth="false" sslProtocol="TLS" />
089
    -->
090
 
091
    <!-- Define an AJP 1.3 Connector on port 8009 -->
092
    <!--
093
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
094
    -->
095
 
096
    <!-- An Engine represents the entry point (within Catalina) that processes
097
         every request.  The Engine implementation for Tomcat stand alone
098
         analyzes the HTTP headers included with the request, and passes them
099
         on to the appropriate Host (virtual host).
100
         Documentation at /docs/config/engine.html -->
101
 
102
    <!-- You should set jvmRoute to support load-balancing via AJP ie :
103
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
104
    -->
105
    <Engine name="Catalina" defaultHost="localhost">
106
 
107
      <!--For clustering, please take a look at documentation at:
108
          /docs/cluster-howto.html  (simple how to)
109
          /docs/config/cluster.html (reference documentation) -->
110
      <!--
111
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
112
      -->
113
 
114
      <!-- Use the LockOutRealm to prevent attempts to guess user passwords
115
           via a brute-force attack -->
116
      <Realm className="org.apache.catalina.realm.LockOutRealm">
117
        <!-- This Realm uses the UserDatabase configured in the global JNDI
118
             resources under the key "UserDatabase".  Any edits
119
             that are performed against this UserDatabase are immediately
120
             available for use by the Realm.  -->
121
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
122
               resourceName="UserDatabase"/>
123
      </Realm>
124
 
125
      <Host name="localhost"  appBase="webapps"
126
            unpackWARs="true" autoDeploy="true">
127
 
128
        <!-- SingleSignOn valve, share authentication between web applications
129
             Documentation at: /docs/config/valve.html -->
130
        <!--
131
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
132
        -->
133
 
134
        <!-- Access log processes all example.
135
             Documentation at: /docs/config/valve.html
136
             Note: The pattern used is equivalent to using pattern="common" -->
137
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
138
               prefix="localhost_access_log." suffix=".txt"
139
               pattern="%h %l %u %t "%r" %s %b" />
140
 
141
      </Host>
142
 
143
 
144
 
145
    </Engine>
146
  </Service>
147
</Server>
148

3、在MyEclipse新建一个tomcat配置项,如下图:

20150401122212

 

20150401122049

2015040112242620150401122537

01
02
<Host name="localhost"  appBase="webapps"
03
            unpackWARs="true" autoDeploy="true">
04
 
05
        <Context path="/" docBase="D:/apache-tomcat-client/webapps/client"/>
06
        <!-- SingleSignOn valve, share authentication between web applications
07
             Documentation at: /docs/config/valve.html -->
08
        <!--
09
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
10
        -->
11
 
12
        <!-- Access log processes all example.
13
             Documentation at: /docs/config/valve.html
14
             Note: The pattern used is equivalent to using pattern="common" -->
15
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
16
               prefix="localhost_access_log." suffix=".txt"
17
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
18
 
19
      </Host>
20

发表评论

回顶部