Import Maven multi-module project into Eclipse

Tuomas Toivonen picture Tuomas Toivonen · Sep 2, 2017 · Viewed 15k times · Source

How do I properly import Maven multi-module project into Eclipse? When I import new Maven project and select the parent pom, I can see the submodules under the parent pom and they are visible in package explorer and project explorer. However, they are presented as deep directory structure, as if eclipse doesn't know they are Java projects.

When I expand the submodule project, I don't see the Java packages shortcuts as I would have opened a single Maven project. I only see it as a deep directory structure. How do I import multimodule Maven project and open the submodule project to take advantage of Eclipse Java project features?

Answer

Black.Jack picture Black.Jack · Sep 2, 2017
  • Install M2E Plugin from Market if it is not already installed
  • From Eclipse IDE choose "File" and "Import" from toolbar. That should lead you to a pop up.
  • Type "Existing Maven Project", or navigate to this voice under Maven settings.
  • Then select main pom project from the import menu, and be sure to select entire tree of projects under it.

Before to approach this clean the IDE from current wrong imported project deleting its maven root pom project and every sub modules, but leave them in the disk obviously. I don't recommend the "Convert" options as sometimes doesn't lead to clean results, especially with big and messy projects. That should do the trick. Let me know if this solves your problem.