Maven and Eclipse tutorial

The toughest thing about building Maven projects in Eclipse is simply getting started. After that, Java development in Eclipse becomes decidedly simpler.

That's because once a Maven project is created in Eclipse, the m2eclipse plugin enables a variety of tools, context menus and features that make it easy for developers to compile, test, package and even deploy Java JAR files to remote Maven repositories.

However, the steps to create that initial Maven project in Eclipse can be confusing, which is why this Maven and Eclipse tutorial will walk you through it.

How to create a Maven project in Eclipse

To create a simple Apache Maven project in the Eclipse IDE, follow these steps:

  1. Select File > New > Maven Project from the top menu.
  2. Choose to skip the archetype selection.
  3. Provide a group ID, artifact ID and version for your project.
  4. Click Finish.

The IDE might take a minute or two to perform an initial build and create the various files and folders that are standard for a Maven project. Once the project creation is complete, you're ready to write some Java code.

Maven features in Eclipse

There's nothing special about writing Java code in a Maven project with Eclipse. For the most part, it's business as usual. However, you'll want to explore various build-specific features and tools that become available to you after your Maven project is created, such as the following:

  • Context menus that enable you to configure environment variables for Maven builds.
  • A custom Maven POM editor to configure external dependencies.
  • Context menus that trigger Maven test, compile and install phases.
  • A Maven repository browser with which to view downloaded ZIP and JAR files.
  • Support for multiple Maven profiles.

The Eclipse IDE greatly simplifies Java development, and Maven greatly simplifies the build process. Integrating the two lets Java developers leverage the best of both worlds.

Cameron McKenzie has been a Java EE software engineer for 20 years. His current specialties include Agile development; DevOps; Spring; and container-based technologies such as Docker, Swarm and Kubernetes.

View All Videos