`
whusl
  • 浏览: 99474 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

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

 
阅读更多

配置好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 [../../../src/share/back/debugInit.c:690]
这是因为监听程序还没有停止,依然绑定在端口上。所以只需要找到这个程序即可。

只需要找到java.exe(前提是你没有其他java进程哦!),结束掉这个即可!

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics