Reputation: 23522
How do I properly import a Maven multi-module project into Eclipse? When I import a new Maven project and select the parent pom, I can see the submodules under the parent pom which are visible in the package explorer and project explorer. However, they are presented as a 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 package shortcuts as I would have if I opened a single Maven project. I only see it as a deep directory structure. How do I import a multimodule Maven project and open the submodule project to take advantage of Eclipse Java project features?
Upvotes: 27
Views: 32019
Reputation: 618
In my case the name of the main project after I cloned it was the same as the name that would have been used for one of the modules. Therefore, after cloning the project, I added a suffix to it to change it. After that the import worked just fine.
Another way of solving, at least in my case, would have been to use a name template when importing the project, one that would make the name of the module different than the main project:
This video helped me get back on the track and find what my problem was: https://youtu.be/aF0xP9SXcrE?si=3LDzzb9gbaQwtoaj.
Upvotes: 0
Reputation: 1957
Before approaching this clean the IDE from the currently wrong imported project, deleting its Maven root pom project and every submodule, but leave them on the disk obviously. I don't recommend the "Convert" options as sometimes that doesn't lead to clean results, especially with big and messy projects.
Upvotes: 16
Reputation: 2857
To add a few on top of @BlackJacks answer, ensure that the parent pom
in the root of the directory that contains sub-projects contains a modules section:
<modules>
<module>module1</module>
<module>module2</module>
<module>module3</module>
</modules>
So, after the import, unlike IntelliJ, Eclipse opens the sub-modules as separate projects, apart from the main root project.
Hope this helps!
Upvotes: 0
Reputation: 155
mvn eclipse:eclipse
File > Open Projects From File System...
pom.xml
fileProject > Clean
from MenuFile> Restrat
From MenuSolved my problem in Eclipse 2019-06(4.12.0) and 2018-12(4.10.0)
When you start to search for files in 'open resource' (for example using Ctrl
+ Shift
+ R
) eclipse will show file from two address. for example MySampleFile
will be available under:
parent-module/sub-module/src/main/java/.../MySampleFile
andsub-module/src/main/java/.../MySampleFile
Use second one. Opening file with first one will not activate IDE features on that file.
Upvotes: 3
Reputation: 199
First, import the parent project. Then, right click on it at the package/project explorer, go to Configure and then click the Configure and Detected Nested Projects..., on the window that will appear click Finish and you're gold.
Also worth mentioning, Package Explorer won't show it nested, use Project Explorer instead.
Have a nice day.
Upvotes: 12
Reputation: 341
For everyone who still have the same issue, follow these steps:
Import Existing Maven Project
wizardPOM.xml
only and click Finish
Right Click
on the project folder, then click on Import
and select his POM.xml
fileHope it helps ! Good Luck !
Upvotes: 6
Reputation: 633
If you are using git or any version control. Clone the repository first in local.
Steps already explain by @Black Jack. Adding image to support
Upvotes: 2
Reputation: 232
Follow the steps
import
import
then type or select Existing Maven Project
Now your moduled project in you workbench. If you have any query we can discuss.
Upvotes: -1