|
配置好jetty后,開發(fā)起來就爽多了。具體配置如下:
一、配置pom.xml文件,添加如下內(nèi)容:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
</plugin>
二、新增一個(gè)外部工具(轉(zhuǎn)載請(qǐng)注明
blog.csdn.net/whuslei)

三、配置maven路徑和jetty執(zhí)行命令

四、然后會(huì)在工具欄看到以下選項(xiàng)

如果沒有出現(xiàn)這個(gè),請(qǐng)自行添加:

五、啟動(dòng)jetty

如果成功會(huì)出現(xiàn):Listening for transport dt_socket at address: *****
-------如果想調(diào)試,怎么辦?接著配置:--------------------------------------------
一、修改environment中的內(nèi)容
New一個(gè)variable,名為MAVEN_OPTS,值為
-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n

二、配置遠(yuǎn)程debug

在彈出的對(duì)話框中選擇

設(shè)置參數(shù),注意這里的端口必須與前面設(shè)置的一致

三、啟動(dòng)遠(yuǎn)程調(diào)試
先啟動(dòng)jetty監(jiān)聽程序,命令行會(huì)出現(xiàn)提示窗口

四、遠(yuǎn)程啟動(dòng)jetty

這樣就可以進(jìn)行調(diào)試了,那如何關(guān)閉呢?
五、設(shè)置關(guān)閉jetty快捷方式,修改POM.xml文檔
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<configuration>
<stopPort>9966</stopPort><!-- 停止jetty -->
<stopKey>foo</stopKey>
</configuration>
</plugin>
六、新建一個(gè)jetty stop命令,很簡(jiǎn)單啦

七、停止調(diào)試

【技巧】
1、先要啟動(dòng)jetty監(jiān)聽端口,才能啟動(dòng)jetty遠(yuǎn)程調(diào)試。
2、如果jetty stop執(zhí)行失敗,再次啟動(dòng)監(jiān)聽端口時(shí)會(huì)出現(xiàn)以下異常:
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]
這是因?yàn)楸O(jiān)聽程序還沒有停止,依然綁定在端口上。所以只需要找到這個(gè)程序即可。

只需要找到j(luò)ava.exe(前提是你沒有其他java進(jìn)程哦!),結(jié)束掉這個(gè)即可!
|