ITeye博客

Maven - How to remote debug web application

huhu_long · 2012-05-09 19:46 · Maven · 项目构建管理 · 研发管理 · Markdown

  1. add dependence in pom.xml

		<dependency>
			<groupId>org.mortbay.jetty</groupId>
			<artifactId>jetty</artifactId>
			<version>6.1.26</version> // not sure why failed if don't specify the version #
		</dependency>

  1. add debugger start up class

package debugger;

import org.mortbay.jetty.Server;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.webapp.WebAppContext;

public class JettyWebStarter {
	public static void main(String[] args) throws Exception {
		Server server = new Server();

		SelectChannelConnector connector = new SelectChannelConnector();
		connector.setPort(80); // change this port number if it is taken by other program
		server.addConnector(connector);

		WebAppContext context = new WebAppContext();

		context.setContextPath("/");
		context.setDescriptor("src/main/webapp/WEB-INF/web.xml");
		context.setResourceBase("src/main/webapp");

		server.setHandler(context);

		server.start();
	}

}

  1. mvn clean install

  2. debug this class and you are able to debug the code now.

-------------------- or you can ----------------- 4. Create a new Program in External Tools Configuration Location: C:\JSpace\Software\apache-maven-3.0.4\bin\mvn.bat Working Directory: ${workspace_loc:/petstore-web} Arguments: jetty:run !!! NOTE, go to Environment Tab !!! please make sure your environment variables are set correctly. MAVEN_OPTS: -Xdebug -Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=n

  1. Create a new Remote Java Application in Debug Configurations use the same Port specified in MAVEN_OPTS.

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。