Maven Jetty Plugin Configuration Guide

Source: Internet
Author: User
Tags command line

Jetty7-This plugin is renamed Jetty-maven-plugin to conform to the MAVEN2 agreement. To prepare for rapid application development in Web applications, see the Multiple Web application source directory.

To run a Web application in jetty, if you follow the MAVEN default procedure (resources files are stored, ${basedir}/src/main/webapp classes files are stored in ${ Project.build.outputDirectory}, Web.xml configuration description ${basedir}/src/main/webapp/web-inf/web.xml), you don't need to configure anything else.

Simply enter:

MVN Jetty:run

This will start your project on a jetty server with port 8080. Jetty will continue to run until the plug-in is explicitly stopped, for example, by pressing <CTRL-C>, or you can use the MVN jetty:stop command.

It is convenient to delegate this plug-in to run a Web application because it can be configured to periodically scan for any changes to Web applications and to deploy Web applications automatically. This eliminates the process of compiling and deploying in the development cycle to be more productive. Any changes you make to the project when you use the IDE will be automatically imported into the currently running Web container so that you can test it immediately.

If, for whatever reason, you can't run an ungrouped Web application, this plugin also supports the Jetty:run-war and jetty:run-exploded commands in the discussion below.

For more information about other commands, consult the MVN jetty:run page, mvn jetty:run-exploded page, mvn jetty:run-war page in the jetty documentation.

Auto-Execute Plug-ins

Sometimes, for example, when doing an integration test, you certainly want to run your project automatically at the start of the test, and stop when the test is complete, not just manually executing MVN jetty:run at the command line.

To do this, you need to create a few <execution> scripts for the jetty plug-in and use <daemon>true</daemon> configuration options to prevent jetty from running indefinitely, Force it to run only when MAVEN is executing.

Pre-integration-test and Post-integration-test, as described in the following pom.xml fragment, are used to trigger execution and shutdown jetty:

<plugin>
<groupid>org.mortbay.jetty</groupid>
<artifactid>maven-jetty-p Lugin</artifactid>
<version>6.1.10</version>
<configuration>
<sc Anintervalseconds>10</scanintervalseconds>
<stopkey>foo</stopkey>
<stopP Ort>9999</stopport>
</configuration>
<executions>
<EXECUTION>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
&L T;configuration>
<scanintervalseconds>0</scanintervalseconds>
;d aemon>true</daemon>
</configuration>
</execution>
<ex         Ecution>
     <id>stop-jetty</id>
<phase>post-integration-test</phase>
&L T;goals>
<goal>stop</goal>
</goals>
</execution
</executions>
</plugin>

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.