Maven – Run Webapp by maven-jetty-plugin

I always think that building a good developing environment for developers are essential in terms of efficiency as well as quality. maven-jetty-plugin let you run the webapp without deploying the .war to Java web container and run debug mode directly in the Eclipse IDE.

I will shows you how to add and run the maven-jetty-plugin in the spring-mvc-trail project we built in


1. Add the maven-jetty-plugin in the pom.xml base on the above spring-mvc-trail project

<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">
	<name>Spring MVC Trial</name>
	<description>Spring MVC Trial</description>
	<!-- Project properties -->
	<!-- Build Configuration -->
						<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
					<requestLog implementation="org.mortbay.jetty.NCSARequestLog">
	<!-- Dependencies -->
		<!-- Spring framework -->
		<!-- Other dependencies -->


2. Run mvn clean install

3. Create a new maven build in Eclipse Run Configuration as follow OR run mvn jetty:run at your project directory which contains the pom.xml in the shell prompt


4. Open the http://localhost:9090/spring-mvc-trial/hello.htm in browser


5. The log written in the to stdout should be printed in the console

[INFO] Started Jetty Server
2010-03-01 22:39:56.922::INFO:  Started SelectChannelConnector@
2010/3/1 下午 10:42:18 springapp.web.HelloController handleRequest
資訊: Returning hello view
stdout - Returning hello view


6. You can also find the requests log at /target as configured in the pom.xml

Done =)

Reference: Maven Jetty Plugin Configuration Guide

About these ads

11 thoughts on “Maven – Run Webapp by maven-jetty-plugin

  1. bsmithennett Smith

    Thanks for the tutorials. You just helped me climb the Java/Eclipse/Maven/Spring/MVC ladder in a major way! I have been trying to learn to build REST web services using SpringMVC by reading this series (, but my knowledge of the fundamentals wasn’t up to the task. With the help of your tutorials I am heading back to give Eugen Paraschiv’s tutorial another read.

    Many thanks!

  2. Pingback: Running a multi-module Maven web app with Jetty, HTTP ERROR: 503 SERVICE_UNAVAILABLE | Build Future Repository

  3. issam

    Thank so much for these explanations. It was so helpful for me !
    Could you please tell me how can I change Jetty port (9090)

    thanks in advance


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s