目前发现的最好最快的直接在ECLIPSE中JETTY调试方式

之前文章提到过用MAVEN2启动JETTY,这里介绍一种直接从ECLIPSE中启动的办法。
 
适用于6.1.3以上,包括6.1.5的JETTY。

它主要是利用了JDK的代码自动更换性能(code hot replace),可以不用重启JETTY就调试、更换资源文件。注意:一定是DEBUG方式运行才有这项功能。

所以应该说这篇文章的方法更好:

在Run->Debug中,New一个Java Application的配置,填入:

org.mortbay.xml.XmlConfiguration

参数填入一个自己的JETTY配置文件:




完成的myjetty.xml配置文件,请将其中的相应目录修改成自己项目的目录:

<? xml version="1.0" ?>
<! DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd" >

<!--  ===============================================================  -->
<!--  Configure the Jetty Server                                       -->
<!--                                                                   -->
<!--  Documentation of this file format can be found at:               -->
<!--  http://docs.codehaus.org/display/JETTY/jetty.xml                 -->
<!--                                                                   -->
<!--  ===============================================================  -->


< Configure  id ="Server"  class ="org.mortbay.jetty.Server" >

    
<!--  ===========================================================  -->
    
<!--  Server Thread Pool                                           -->
    
<!--  ===========================================================  -->
    
< Set  name ="ThreadPool" >
      
<!--  Default bounded blocking threadpool 
      
-->
      
< New  class ="org.mortbay.thread.BoundedThreadPool" >
        
< Set  name ="minThreads" > 10 </ Set >
        
< Set  name ="maxThreads" > 250 </ Set >
        
< Set  name ="lowThreads" > 25 </ Set >
      
</ New >

      
<!--  Optional Java 5 bounded threadpool with job queue 
      <New class="org.mortbay.thread.concurrent.ThreadPool">
        <Set name="corePoolSize">250</Set>
        <Set name="maximumPoolSize">250</Set>
      </New>
      
-->
    
</ Set >



    
<!--  ===========================================================  -->
    
<!--  Set connectors                                               -->
    
<!--  ===========================================================  -->
    
<!--  One of each type!                                            -->
    
<!--  ===========================================================  -->

    
<!--  Use this connector for many frequently idle connections
         and for threadless continuations.
    
-->     
    
< Call  name ="addConnector" >
      
< Arg >
          
< New  class ="org.mortbay.jetty.nio.SelectChannelConnector" >
            
< Set  name ="port" >< SystemProperty  name ="jetty.port"  default ="8080" /></ Set >
            
< Set  name ="maxIdleTime" > 30000 </ Set >
            
< Set  name ="Acceptors" > 2 </ Set >
            
< Set  name ="statsOn" > false </ Set >
            
< Set  name ="confidentialPort" > 8443 </ Set >
        
< Set  name ="lowResourcesConnections" > 5000 </ Set >
        
< Set  name ="lowResourcesMaxIdleTime" > 5000 </ Set >
          
</ New >
      
</ Arg >
    
</ Call >

    
<!--  Use this connector if NIO is not available.
    <Call name="addConnector">
      <Arg>
          <New class="org.mortbay.jetty.bio.SocketConnector">
            <Set name="port">8081</Set>
            <Set name="maxIdleTime">50000</Set>
            <Set name="lowResourceMaxIdleTime">1500</Set>
          </New>
      </Arg>
    </Call>
    
-->

    
<!--  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  -->
    
<!--  To add a HTTPS SSL listener                                      -->
    
<!--  see jetty-ssl.xml to add an ssl connector. use                   -->
    
<!--  java -jar start.jar etc/jetty.xml etc/jetty-ssl.xml              -->
    
<!--  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  -->
    
    
<!--  ===========================================================  -->
    
<!--  Set up global session ID manager                             -->
    
<!--  ===========================================================  -->
    
<!--
    <Set name="sessionIdManager">
      <New class="org.mortbay.jetty.servlet.HashSessionIdManager">
        <Set name="workerName">node1</Set>
      </New>
    </Set>
    
-->

    
<!--  ===========================================================  -->
    
<!--  Set handler Collection Structure                             -->  
    
<!--  ===========================================================  -->
    
< Set  name ="handler" >
      
< New  id ="Handlers"  class ="org.mortbay.jetty.handler.HandlerCollection" >
        
< Set  name ="handlers" >
         
< Array  type ="org.mortbay.jetty.Handler" >
           
< Item >
             
< New  id ="Contexts"  class ="org.mortbay.jetty.handler.ContextHandlerCollection" />
           
</ Item >
           
< Item >
             
< New  id ="DefaultHandler"  class ="org.mortbay.jetty.handler.DefaultHandler" />
           
</ Item >
           
< Item >
             
< New  id ="RequestLog"  class ="org.mortbay.jetty.handler.RequestLogHandler" />
           
</ Item >
         
</ Array >
        
</ Set >
      
</ New >
    
</ Set >
    
< Set  name ="handler" >    
  
< New  id ="Handlers"  class ="org.mortbay.jetty.handler.HandlerCollection" >    
    
< Set  name ="handlers" >    
      
< Array  type ="org.mortbay.jetty.Handler" >    
        
<!-- Item>   
          <New id="RequestLog" class="org.mortbay.jetty.handler.RequestLogHandler"/>   
        </Item
-->    
        
< Item >    
          
< New  class ="org.mortbay.jetty.webapp.WebAppContext" >    
            
< Set  name ="contextPath" > /ebnms </ Set >    
            
< Set  name ="resourceBase" > E:/Prj2/ForMe/Src/flower/src/main/webapp </ Set >    
            
< Call  name ="addServlet" >    
              
< Arg > org.mortbay.jetty.servlet.DefaultServlet </ Arg >    
              
< Arg > / </ Arg >    
            
</ Call >    
          
</ New >    
    
</ Item >    
      
</ Array >    
    
</ Set >    
  
</ New >    
</ Set >    


    
<!--  ===========================================================  -->
    
<!--  Configure Authentication Realms                              -->
    
<!--  Realms may be configured for the entire server here, or      -->
    
<!--  they can be configured for a specific web app in a context   -->
    
<!--  configuration (see $(jetty.home)/contexts/test.xml for an    -->
    
<!--  example).                                                    -->
    
<!--  ===========================================================  -->
    
< Set  name ="UserRealms" >
      
< Array  type ="org.mortbay.jetty.security.UserRealm" >
        
<!--
        <Item>
          <New class="org.mortbay.jetty.security.HashUserRealm">
            <Set name="name">Test Realm</Set>
            <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
          </New>
        </Item>
    
-->
      
</ Array >
    
</ Set >

    
<!--  ===========================================================  -->
    
<!--  Configure Request Log                                        -->
    
<!--  Request logs  may be configured for the entire server here,  -->
    
<!--  or they can be configured for a specific web app in a        -->
    
<!--  contexts configuration (see $(jetty.home)/contexts/test.xml  -->
    
<!--  for an example).                                             -->
    
<!--  ===========================================================  -->
    
<!-- Ref id="RequestLog">
      <Set name="requestLog">
        <New id="RequestLogImpl" class="org.mortbay.jetty.NCSARequestLog">
          <Set name="filename"><SystemProperty name="jetty.logs" default="./logs"/>/yyyy_mm_dd.request.log</Set>
          <Set name="filenameDateFormat">yyyy_MM_dd</Set>
          <Set name="retainDays">90</Set>
          <Set name="append">true</Set>
          <Set name="extended">true</Set>
          <Set name="logCookies">false</Set>
          <Set name="LogTimeZone">GMT</Set>
        </New>
      </Set>
    </Ref
-->

    
<!--  ===========================================================  -->
    
<!--  extra options                                                -->
    
<!--  ===========================================================  -->
    
< Set  name ="stopAtShutdown" > true </ Set >
    
< Set  name ="sendServerVersion" > true </ Set >
    
<!-- Set name="sendDateHeader">true</Set -->
    
<!-- Set name="gracefulShutdown">1000</Set -->
</ Configure >

posted on 2007-09-13 21:04 我爱佳娃 阅读(4168) 评论(7)   编辑   收藏 所属分类: 服务配置

 


评论:
#  re: 目前发现的最好最快的直接在ECLIPSE中JETTY调试方式 2007-09-16 13:56 | shiqiang124@gmail.com
可以再详细点吗?
是不是在多个

<modules>
<module>core</module>
<module>web</module>
</modules>
也可以这种方式?   回复   更多评论
  
#  re: 目前发现的最好最快的直接在ECLIPSE中JETTY调试方式[未登录] 2007-09-16 14:21 | 我爱佳娃
没明白你的意思呀?我就是这样在ECLIPSE中配置的,调试和动态代码替换都没问题。没有多加什么配置。好像这也不是JETTY的配置指令呀?   回复   更多评论
  
#  re: 目前发现的最好最快的直接在ECLIPSE中JETTY调试方式 2007-09-30 11:27 | 草鞋超人
Jetty的XML configuration 实在是太晕了,官网的文档里也说得语焉不详。难道真的要让人去看code吗?还是逼人买他的Consultant 服务啊……

这里想提一个问题,在myjetty.xml配置文件中,如果想加入jndi的data source的话,应该设置在什么地方啊?放在WEB-INF/jetty-env.xml中的时候总是读不出来。而如果用jetty-maven-plugin的话都是没问题的,而且jetty-env.xml也不一定要放在WEB-INF下面。可以在pom.xml中这样指定:

<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<jettyEnvXml>${basedir}/src/test/jetty/jetty-env.xml</jettyEnvXml>
<connectors>
<connector implementation="org.mortbay.jetty.bio.SocketConnector">
<port>${localPort}</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
</configuration>

而且运行也很正常,可是用楼主的方法的话,就怎么都不行了,真是痛苦死了,好想用这种方式在eclipse里debug啊……   回复   更多评论
  
#  re: 目前发现的最好最快的直接在ECLIPSE中JETTY调试方式 2008-04-30 14:55 | ll
very good!
但是,修改jsp文件报文件锁定,不能修改啊   回复   更多评论
  
#  re: 目前发现的最好最快的直接在ECLIPSE中JETTY调试方式 2008-04-30 20:55 | 我爱佳娃
不会呀,我用了很久了,修改JSP和JS文件都不用重启服务器,修改函数内的代码也不需要重启,只有你加新的方法时才会提示重启。   回复   更多评论
  
#  re: 目前发现的最好最快的直接在ECLIPSE中JETTY调试方式[未登录] 2008-06-04 14:36 | alfred
jettyluncher   回复   更多评论
  
#  re: 目前发现的最好最快的直接在ECLIPSE中JETTY调试方式 2008-06-04 20:39 | 我爱佳娃
我现在每天都在用此博文所指的工具,非常舒服。

楼上指的是这个吗: http://jettylauncher.sourceforge.net/

我不想再试,有兴趣可以尝试下,好像已经停止开发了。
Development on this project ended
The plugin supports only Eclipse 2.x versions and older versions of Jetty (5.x and downwards) and the JVM (1.4/ 1.5)   回复   更多评论
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值