eclipse中利用jetty進行Maven web項目開發調試__web

來源:互聯網
上載者:User

       配置好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進程哦。),結束掉這個即可。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.