MAVEN Eclipse Debug

Source: Internet
Author: User

Preparatory work:

A. Configure the jetty plugin in Pom.xml:

XML code
  1. <plugins>
  2. <plugin>
  3. <groupId>org.mortbay.jetty</groupId>
  4. <artifactid>maven-jetty-plugin</artifactid>
  5. <version>6.1.26</version>
  6. <configuration>
  7. <webappsourcedirectory>src/main/webapp</webappsourcedirectory >
  8. <scanintervalseconds>6</scanintervalseconds>
  9. <contextpath>/prospect</contextpath>
  10. <webdefaultxml>jetty.xml</webdefaultxml>
  11. <jettyenvxml>jetty-env.xml</jettyenvxml>
  12. <connectors>
  13. <connector implementation="Org.mortbay.jetty.nio.SelectChannelConnector">
  14. <port>8080</port>
  15. <headerbuffersize>80000</headerbuffersize>
  16. </connector>
  17. </connectors>
  18. <stopkey>stop</stopkey>
  19. <stopport>8089</stopport>
  20. </configuration>
  21. </plugin>
  22. </plugins>
[XML]View Plaincopy
  1. <plugins>
  2. <plugin>
  3. <groupId>org.mortbay.jetty</groupId>
  4. <artifactid>maven-jetty-plugin</artifactid>
  5. <version>6.1.26</version>
  6. <configuration>
  7. <webappsourcedirectory>src/main/webapp</webappsourcedirectory>
  8. <scanintervalseconds>6</scanintervalseconds>
  9. <contextpath>/prospect</contextpath>
  10. <webdefaultxml>jetty.xml</webdefaultxml>
  11. <jettyenvxml>jetty-env.xml</jettyenvxml>
  12. <connectors>
  13. <connector implementation="Org.mortbay.jetty.nio.SelectChannelConnector">
  14. <Port>8080</port>
  15. <headerbuffersize>80000</headerbuffersize>
  16. </connector>
  17. </connectors>
  18. <stopkey>stop</stopkey>
  19. <stopport>8089</stopport>
  20. </configuration>
  21. </plugin>
  22. </plugins>



B. Use maven's clean install command to package the Web and dependent projects into war files.


Mode 1-eclipse Debug:

①. Right-click Maven Project, select [Debug as] in the popup menu, first select [Maven build ...], select [Maven build] later to read the saved configuration start:


②. In the browser input address http://localhost:8080/prospect/already/mosaic.htm, add a breakpoint on the code, after hitting the IDE prompt: Source not found:


Solve:
Click [Edit Source Lookup Path ...] Add source code project or catalog

Debug your code when you're done:



mode 2-Remote debugging:

①. Select Eclipse's [run]-[external tools]-[external Tools configurations ...] Menu.

In the dialog box that opens, create a new program, enter the full path of Mvn.bat (Mvndebug.bat), specify the Web project to start, enter Jetty:run



in the Arguments box When using Mvn.bat, you need to add Debug parameters:
Switch to Environment option, add a variable:
Maven_opts=-xdebug-xrunjdwp:transport=dt_socket,server=y, suspend=n,address=1066

Note: address is the port that communicates with the debugger, not the service's port number.



Additional parameters:
-xnoagent: Disabling the default Sun.tools.debug debugger
-djava.compiler=none: Suppress loading of the JIT compiler
Dt_shmem: Shared memory transfer, limited to Windows


Select Eclipse's [Run]-[debug Configurations ...] menu, in the popup dialog box, create a new remote Java application, specifying the same project and connection properties as the external tools:



Click [Debug] to start the debug client



②. The same way 1 of the ②


Attached:
I. The JVM for remote debugging can run independently of Eclipse:


At this point, only the debug client in Eclipse:


Ii. If suspend=y runs the JVM without turning on the debug client, the JVM waits until the client is ready:

    • Size: 61.6 KB
    • Size: 20.3 KB
    • Size: 29.4 KB
    • Size: 42.9 KB
    • Size: 64.5 KB
    • Size: 54.8 KB
    • Size: 16.9 KB
    • Size: 20.2 KB
    • Size: 12.8 KB
    • Size: 6 KB
    • View Picture Attachments

(EXT) MAVEN Eclipse debug

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.