Debug maven jetty application in Eclipse

Maven and Jetty have a good integration, you can easily use mvn jetty:run to start a web application, but the default maven-jetty plugin does not enable debug mode, and it is inevitable to use IDE debug reference in daily development. The following describes how to configure eclipse so that it can debug the maven-jetty project.

 1. First set the startup method.

Open the configuration window in Ecipse ->Run->External Tools ->External Tool Configuration..., select the Program node, and double-click to create a new configuration.

 

Name is customized, under Main Tab, Location is set to the path of the mvn command, Working Directory is set to the project directory that needs to be debugged, and Arguments is set to jetty:run

Create a new environment variable MAVEN_OPTS in the Envriroment Tab with the value

-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8089,server=y,suspend=y

Click Apply to save the configuration; close to close the window.

2. Set Debug information

Open the Eclipse->Run->Debug Configurations window and select Create a new Remote Java Application configuration in the list on the left. Under the Connect Tab, Project is set to the project that currently needs to be debugged, Host is set to localhost, and the port is 8089 (address=8089 in MAVEN_OPTS above)

 

Click Apply to save the configuration, close to close the window

 

3. Run the application.

Eclipse->Run->External Tools->Extrernal Tools Configurations, select the startup configuration set in the first step, execute Run, and start the application. Eclipse terminal will output

 

Listening for transport dt_socket at address: 8089

Indicates that the application starts listening on debug port 8089

 

4. Enable debug

Eclipse->Run->Debug Configurations Select the debug configuration set in the second step to start debug

 

 

http://jiangbo.me/blog/2011/08/10/eclipse-debug-maven-jetty/

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326671212&siteId=291194637
Recommended