如何实现在myeclipse和eclipse中,修改代码后实现自动加载,不用频繁的手动启动tomcat

【1】eclipse

eclipse中如何让Tomact自动部署项目,实现免手动启动的问题:

(1)找到tomcat的配置文件 server.xml,配置项:

<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">

(2)增加<Context />这个配置项,配置如下:

 <Context docBase="licaipay" path="/licaipay" reloadable="true"  source="org.eclipse.jst.j2ee.server:licaipay"/>

(3)重新启动tomcat项目,修改代码可看到tomcat自动重新启动,证明配置成功

如果出现eclipse processworkerexit 的这个错误,解决方法如下:

Window--》Preferences 在搜索框内输入 suspend  回车搜索后 ,点击debug ,右侧选项上 取消勾选 suspend execution  on caught exceptions,勾选这个的意思就是:暂停对未捕获的异常进行异常(主要是针对eclipse中报eclipse processworkerexit 的这个错误)

【2】myeclipse

在myeclipse中,需要找到tomcat的配置文件sercer.xml,

修改位置项:

  <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
    <Context docBase="E:\work_space\p2b_new\WebRoot\" path="" reloadable="true"/>
 <!-- SingleSignOn valve, share authentication between wseb applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->
        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" 
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log." suffix=".txt"/> -->
      </Host>

其中:

<Context docBase="E:\work_space\p2b_new\WebRoot\" path="" reloadable="true"/>

docBase是项目的部署DOC,这里一定是你编译后项目的路径的webRoot目录下,否则实现不了自动部署

path是项目上下文路径
reloadable一定设置为true,这个是自动加载(使用的若是外带的tomcat)

如果你用的是myeclipse自带的tomcat的话,修改代码后,myeclipse是可以自动部署的

同样的如果遇到 processWorkerExit 这个问题:同样的也是在Windows ->Perferences->取消都选 suspend execution  on caught exceptions 

如图所示:



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章