Trouble importing multi module maven project in to Eclipse (STS 2.5.2)

19,950

Solution 1

M2Eclipse does a very good job at resolving inter-project dependencies. If it doesn't work, perhaps your project structure has errors. Check that:

  • every child project references the correct version of the parent project
  • every dependency has the version that corresponds to the current project version in the workspace
  • every child project is registered as a <module> in the parent pom (profile must be active if the module is defined in a profile).

If these versions don't match, the artifacts referenced will be pulled from the local repository, not the eclipse workspace.


About common root projects: I don't think it's a good idea to have a common Project, but the Eclipse concept that comes to mind (and that I use for multi-module projects) is a Working Set.

In the Package Explorer, switch the Top Level Elements to Working Sets:

Top Level Elements > Working Sets

Now choose Configure Working Sets ... from the same menu.

Here's a working set with the maven3 trunk and all submodules as separate projects:

multi module working set

Solution 2

Ugly trick - but sometimes can help:

  • mvn clean eclipse:clean eclipse:eclipse
  • Import projects as usual Eclipse project
  • enable Maven's Dependency Management
  • Perform Update Project Configuration for all modules
Share:
19,950
C0deAttack
Author by

C0deAttack

Just a casual coder

Updated on June 27, 2022

Comments

  • C0deAttack
    C0deAttack almost 2 years

    I've just spent the last hour looking at threads on Stackoverflow.com , trying to import a Maven project in to Spring ToolSuite 2.5.2.

    The Maven project has multiple modules, when I use the Import... wizard in STS to import the project All the Modules are listed in the Package Explorer and some of the modules dependencies are not resolved.

    Can any advise on the proper way to import a Multi-Module Maven project in to STS/Eclipse such that all the modules appear under a Parent directory? And so all the modules dependencies are resolved?

    The project is in a hierarchy on the file system, I've tried the various Update Dependencies, Project Configuration options but all to no avail. I have an embedded version of Maven installed in the IDE.

    Thanks for your time.