Run web application with Maven Jetty Plugin

In this tutorial, I will introduce with all of you about a Maven plugin, which can help us run a web application in Jetty with some simple configurations. This is Maven Jetty Plugin.

First of all, we need a web project using Maven for example.

I use Spring Tool Suite to create an example Maven project for this tutorial.

If you don’t know how to create a web project in Spring Tool Suite IDE, you can look at this tutorial.

Our project structure as below:

Run web application with Maven Jetty Plugin

Now, I will add Maven Jetty Plugin into our project.

Currently, the latest version of Jetty is 9.3.0.v20150612. This is also latest version of Maven Jetty Plugin! Look at version, we can know no update for Jetty for a long time :).

OK, now we can run our application.

Let right-click on the project or the pom.xml file, then choose Run As and select Maven build…

The window Run Configurations will appear, let enter clean jetty:run into field Goals as below:

Run web application with Maven Jetty Plugin

After that press Run button, Maven will build our project and run it on Jetty server with default port is 8080, root context path will be “/”, this mean you only need run http://localhost:8080 then you can see the web page.

Result:

Run web application with Maven Jetty Plugin

To change the root context path of our web application, you can add more configuration for Maven Jetty Plugin in the pom.xml file as below:

Run again, result as below:

Run web application with Maven Jetty Plugin

If you want to change the port number, you also can add more configuration for Maven Jetty Plugin as below:

Result

Run web application with Maven Jetty Plugin

 

Chia sẽ bài viết này ...Share on Facebook
Facebook
0Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin

Add Comment