Alejandro Duarte

Importing a Maven project in IntelliJ IDEA

This tutorial explains how to import an existing Maven project into IntelliJ IDEA and how to create a running configuration for a Maven goal. This is useful, for example, when using the Jetty Maven plugin that allows you to quickly deploy and run a Java web application using this popular server.

Maven is a project management tool that goes beyond dependency management. See Learning Maven Concepts to learn more.

Download an existing Maven project

This tutorial uses a Maven archetype that generates a web application with a preconfigured Jetty Maven Plugin in it:

mvn -B archetype:generate -DarchetypeGroupId=com.vaadin -DarchetypeArtifactId=vaadin-archetype-application -DarchetypeVersion=LATEST -DgroupId=org.test -DartifactId=webapp -Dversion=1.0-SNAPSHOT
If you prefer, you can generate a ZIP file with the project at or Make sure you select the Plain Java Servlet option before downloading the project.

The project should include a directory with a Maven project in it:

Maven project directory
You need Node.js installed on your computer to compile the example application.

Import the project

There are several ways to import a Maven project in IntelliJ IDEA. The most common approach is to open the pom.xml file directly. You can do it in the welcome screen by clicking Open:

Welcome screen
Import Project gives you more options to tweak the import process. However, this is out of the scope of this tutorial.

Select the pom.xml file of the Maven project you want to import and click Open as Project.

The welcome window is only shown when you close all projects in IntelliJ IDEA. If you don’t want to close your currently opened projects, you can select File > Open in the menu instead.

Running Maven goals

IntelliJ IDEA has an excellent integration with Maven. You can run common commands such as mvn install or mvn jetty:run without having to leave the IDE.

Open the Maven view by clicking the corresponding option on the left side of the IntelliJ IDEA window:

Maven projects view

This view shows all the available Maven projects and their build phases and build goals. Let’s say you want to run mvn install. To do that, expand the project tree in the Maven view to show the corresponding lifecycle phase and then double-click install:

Lifecycle phases

You’ll see how IntelliJ idea executes the install build phase (and all the previous phases in the Maven’s default lifecycle) that downloads dependencies and copies the generated artifacts into your local Maven repository, among other things.

You can use a similar approach to run any Maven goal. For example, you can double-click the jetty:run goal in the Plugins sub-tree to deploy and run the web application implemented in the project you imported. Similarly, if you are using Spring Boot, you can double-click spring-boot:run to run the application.

Creating a running configuration

Since using the jetty:run goal could be a frequent task during the development of a Java web application, you may prefer to create a running configuration for it.

A running configuration is a shortcut to run a specific task from within the IDE. Let’s create a running configuration for the jetty:run Maven goal to make it simpler to run the web application.

Right-click the jetty:run option in the Maven view and select Create 'webapp [jetty:run]':

Create running configuration option

For simplicity, change the name of the configuration to Run on Jetty and click OK:

Run on Jetty
If you are using Spring Boot, use the spring-boot:run goal.

You should see the new option on the top right corner of IntelliJ IDEA:

Running configuration created

Now you can deploy and run the web application by clicking the run (or the debug) icon in the toolbar:

Run icon
If you use the Vaadin project used in the tutorial, you can invoke the web application at http://localhost:8080.

That’s it. Now you can use IntelliJ IDEA to develop your Maven application. To learn more about:

Vaadin is an open-source framework offering the fastest way to build web apps on Java backends

Comments (6)

Marcus Hellberg
2 years ago May 07, 2020 10:17pm
Shourya Bansal
2 years ago May 08, 2020 12:30am
Marcus Hellberg
2 years ago May 08, 2020 7:17pm
Alejandro Duarte
2 years ago Jan 21, 2020 1:48pm