痴心VS绝对 发表于 2017-2-27 12:25:47

eclipse中利用jetty进行Maven web项目开发调试

         eclipse中利用jetty进行Maven web项目开发调试            
               
                  分类:             软件使用心得            JAVA学习               2011-07-30 21:24   52人阅读   评论(0)   收藏   举报            
         配置好jetty后,开发起来就爽多了。具体配置如下:
         一、配置pom.xml文件,添加如下内容:
      <plugin>
               <groupId>org.mortbay.jetty</groupId>
               <artifactId>maven-jetty-plugin</artifactId>
         </plugin>
         二、新增一个外部工具(转载请注明 blog.csdn.net/whuslei)
      
         三、配置maven路径和jetty执行命令
      
         四、然后会在工具栏看到以下选项
      
      如果没有出现这个,请自行添加:
      
         五、启动jetty
      
      如果成功会出现:Listening for transport dt_socket at address: *****
  -------如果想调试,怎么办?接着配置:--------------------------------------------
         一、修改environment中的内容
      New一个variable,名为MAVEN_OPTS,值为
      -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n
      
         二、配置远程debug
      
      在弹出的对话框中选择
      
      设置参数,注意这里的端口必须与前面设置的一致
      
         三、启动远程调试
      先启动jetty监听程序,命令行会出现提示窗口
      
         四、远程启动jetty
      
      这样就可以进行调试了,那如何关闭呢?
         五、设置关闭jetty快捷方式,修改POM.xml文档
      <plugin>
               <groupId>org.mortbay.jetty</groupId>
               <artifactId>maven-jetty-plugin</artifactId>
               <configuration>
                   <stopPort>9966</stopPort><!-- 停止jetty -->
                   <stopKey>foo</stopKey>
               </configuration>

         </plugin>
         六、新建一个jetty stop命令,很简单啦
      
         七、停止调试
      
         【技巧】
      1、先要启动jetty监听端口,才能启动jetty远程调试。
      2、如果jetty stop执行失败,再次启动监听端口时会出现以下异常:
      FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
      ERROR: transport error 202: bind failed: Address already in use
      ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
      JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized
      这是因为监听程序还没有停止,依然绑定在端口上。所以只需要找到这个程序即可。
      
      只需要找到java.exe(前提是你没有其他java进程哦!),结束掉这个即可!
页: [1]
查看完整版本: eclipse中利用jetty进行Maven web项目开发调试