您的最后一段确实给出了合理的解决方案。
如果导入器和 Web 应用程序是密切相关的,并且这些“公共类”的“可重用性”仅在这个项目中,你可以做一个像这样的多模块项目:
foo // your project name
+ foo-main // your reusable classes, you may split it into several modules if appropriate
+ foo-web // have foo-main as dependency
+ foo-importer // have foo-main as dependency
+ foo-parent // my personal preference is to make parent project a module, not mandatory
如果你的 importer 和你的 foo 项目无关,但你还是想复用,可以拆分出来
foo // your project name
+ foo-main // your reusable classes, you may split it into several modules if appropriate
+ foo-web // have foo-main as dependency
+ foo-parent // my personal preference is to make parent project a module, not mandatory
bar-importer // another project, having foo-main as dependency
甚至将公共代码作为一个单独的项目
app-common // the common code in original foo-main,
// maybe a multi-module project
foo // your project name
+ foo-main // foo-specific codes, have app-common as dependency
+ foo-web // have foo-main as dependency
bar-importer // having app-common as dependency
对于 Eclipse,应该没有什么可担心的。鉴于您使用的是最新的 Eclipse + M2E 插件(应该已经与最新的 Eclipse 捆绑在一起),如果您有正确的 POM,当您将项目导入 Eclipse 时(通过 Import -> Existing Maven Project),项目之间的关系应该已经创建.