Preparatory work:
A. Configure the jetty plugin in Pom.xml:
XML code
- <plugins>
- <plugin>
- <groupId>org.mortbay.jetty</groupId>
- <artifactid>maven-jetty-plugin</artifactid>
- <version>6.1.26</version>
- <configuration>
- <webappsourcedirectory>src/main/webapp</webappsourcedirectory >
- <scanintervalseconds>6</scanintervalseconds>
- <contextpath>/prospect</contextpath>
- <webdefaultxml>jetty.xml</webdefaultxml>
- <jettyenvxml>jetty-env.xml</jettyenvxml>
- <connectors>
- <connector implementation="Org.mortbay.jetty.nio.SelectChannelConnector">
- <port>8080</port>
- <headerbuffersize>80000</headerbuffersize>
- </connector>
- </connectors>
- <stopkey>stop</stopkey>
- <stopport>8089</stopport>
- </configuration>
- </plugin>
- </plugins>
[XML]View Plaincopy
- <plugins>
- <plugin>
- <groupId>org.mortbay.jetty</groupId>
- <artifactid>maven-jetty-plugin</artifactid>
- <version>6.1.26</version>
- <configuration>
- <webappsourcedirectory>src/main/webapp</webappsourcedirectory>
- <scanintervalseconds>6</scanintervalseconds>
- <contextpath>/prospect</contextpath>
- <webdefaultxml>jetty.xml</webdefaultxml>
- <jettyenvxml>jetty-env.xml</jettyenvxml>
- <connectors>
- <connector implementation="Org.mortbay.jetty.nio.SelectChannelConnector">
- <Port>8080</port>
- <headerbuffersize>80000</headerbuffersize>
- </connector>
- </connectors>
- <stopkey>stop</stopkey>
- <stopport>8089</stopport>
- </configuration>
- </plugin>
- </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:
(EXT) MAVEN Eclipse debug