简体   繁体   中英

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

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.

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 :

顶级元素>工作集

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

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

多模块工作集

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM