DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Deploy Maven Apps to Kubernetes With JKube Kubernetes Maven Plugin
  • Using Maven and Without Drools Eclipse Plugin
  • Cookies Revisited: A Networking Solution for Third-Party Cookies
  • How to Build a New API Quickly Using Spring Boot and Maven

Trending

  • Medallion Architecture: Why You Need It and How To Implement It With ClickHouse
  • Event-Driven Architectures: Designing Scalable and Resilient Cloud Solutions
  • Unlocking the Potential of Apache Iceberg: A Comprehensive Analysis
  • Issue and Present Verifiable Credentials With Spring Boot and Android
  1. DZone
  2. Coding
  3. Frameworks
  4. Importing a Maven Project in Eclipse

Importing a Maven Project in Eclipse

By 
Alejandro Duarte user avatar
Alejandro Duarte
DZone Core CORE ·
Dec. 17, 19 · Tutorial
Likes (6)
Comment
Save
Tweet
Share
30.0K Views

Join the DZone community and get the full member experience.

Join For Free

This tutorial explains how to import an existing Maven project into Eclipse and how to create a run 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 for more.

Download an Existing Maven Project

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

Shell
 




x


 
1
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 https://vaadin.com/start/latest or https://start.vaadin.com. Make sure you select the Plain Java Servlet option before downloading the project.

You may also like: Building Java Applications With Maven.

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


  1. In Eclipse, select File > Import…
  2. In the import window, expand Maven, select Existing Maven Projects, and click Next: Import window
  3. Click Browse, and select the directory that contains the pom.xml file of the project you want to import: Select the root directory

    If you are importing a multi-module Maven project, make sure you select the correct project to import. You will typically want to select all the projects.
  4. Click Finish. Eclipse will import the project and start downloading the required resources.

Running Maven goals

Eclipse has built-in integration with Maven. You can run common commands, such as  mvn install or  mvn jetty:run without having to leave the IDE.

The most common commands are available in the Run As and Debug As folders when you right-click the project in Project Explorer view. For example, to run  mvn install, right-click the project and select Run As > Maven install:

Maven install

You can find additional useful options in the Maven submenu.

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

Creating a Run Configuration

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

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


  • Right-click the project in the Project Explorer view and select Run As > Maven build.
  • In the Edit Configuration window, for Goals type jetty:run and optionally give the run configuration a new name: jetty:run configuration
  • Click Run to save the new configuration and execute it. You should see the Console view with the log generated by the application and the Jetty server.
  • To stop the server, click the Terminate icon in the Console view: Terminate You can deploy and run the web application by clicking the run (or the debug) icon in the toolbar and selecting the corresponding run or debug configuration:


Toolbar

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 Eclipse to develop your Maven application. To learn more about:

  • How to develop a Java web application without coding JavaScript or HTML, see Vaadin quick start tutorial.

Further Reading

  • Beginner's Guide to Creating a Maven Plugin.
  • 10 Effective Tips on Using Maven.
  • Gradle vs. Maven.
Apache Maven Eclipse Web application

Published at DZone with permission of Alejandro Duarte. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Deploy Maven Apps to Kubernetes With JKube Kubernetes Maven Plugin
  • Using Maven and Without Drools Eclipse Plugin
  • Cookies Revisited: A Networking Solution for Third-Party Cookies
  • How to Build a New API Quickly Using Spring Boot and Maven

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!