Eclipse uses jetty to debug Maven project __maven

Source: Internet
Author: User
Tags java web
Maven jetty Eclipse run stop debug Debug Java Web Project

The most obvious advantage of Maven in front of us is the management of the Peoject jar package. Of course maven's advantages are much more than that.

Under Eclipse, you can use M2eclipse to speed up the development of MAVEN project.

When you debug your Web project for maven these days, you find that you cannot shut down a Web project that is already running, only in the Task Manager

End the process. This is depressed, online looking for, also by the way summed up a bit.

Start "", "" "" "" "" "," "

Step 1. How to start a Web project for debugging:

1.1 I am using the jetty container. First, you configure the plugin in Pom.xml

<!--jetty Plugin-->
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
</plugin>

1.2 Below configure an external tool to run jetty.

Select Menu Run->external tools->external Tools Configurations

--------------------》

Figure 1

Select Program on the left, then right-click NEW:
Configure location as the MVN command-line path.

Select working directory for the project you want to run currently.

Arguments fill in: Jetty:run as shown in Figure 2


Figure 2

After this operation, click Run, or point to Figure 3

Figure 3
You can run the project.

But at this point, it's just running the project and it's not up to the debug requirements.

2. Debug debugging the Web project,

2.1 In the click of the Environment option in Figure 2, add one, Environment varibles.

Add maven_opts variable, value is

-xdebug-xnoagent-djava.compiler=none-xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n

2.2 Under the Debug run configuration, click Debug->debug Configuration

Select the appropriate project in the configuration, and the port will be set to the same as the address=4000 in the maven_opts variable.



After the configuration is complete, you can set breakpoints for debug debugging.

First start the Web project in step 1, and then run the newly created remote Java application.

The following figure:


3. Finally, Jetty's shutdown.

3.1 First in the Pom.xml.
<!--jetty Plugin-->
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
</plugin>

Modified to------------------->>>>>>>

<!--jetty Plugin-->
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<configuration>
<stopPort>9966</stopPort>
<stopKey>foo</stopKey>
</configuration>
</plugin>

First as shown in Figure 1, new


Then run the new program to shutdowm the jetty project that will run.

End "The" "" "The" "" "The" "" "The"

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.