当导入到新的eclipse工作区时,maven multi模块不保留映射模块

时间:2011-01-28 21:59:01

标签: eclipse module maven workspace

我使用eclipse和m2eclipse插件创建了一个maven多模块项目: 首先:我使用eclipse创建了一个父项目(选择menu \ New \ Maven项目),然后右键单击该项目并单击New \ Other \ MavenModule)。我有2个模块。 通过使用这种方式,在项目资源管理器面板上,我可以看到一个父项目和2个模块,如下所示:

  - parent
         - module 1
         - module 2
  - module 1 (mapping from module 1 that stay inside parent)
  - module 2 (mapping from module 2, whatever you change here will be reflect to module 2 that stay inside parent)

我喜欢这种方式,因为我可以将模块视为真正的eclipse项目,我可以右键单击模块并执行Clean或Build。

但现在问题发生在我创建一个新工作区并将父项目导入新工作区(我仍然使用相同的eclipse)时,模块映射消失了。现在在新工作区中,我能看到的是:

-parent
      - module 1
      - module 2

新面貌太不方便了。我没有能力像现实项目那样对待模块了。

我的问题是如何解决这个问题?我想要的是当导入到一个新的工作区时,该项目仍然具有映射模块。

1 个答案:

答案 0 :(得分:0)

转到工作区父文件夹尝试运行此

    mvn eclipse:eclipse

在此处查看它的作用:http://maven.apache.org/plugins/maven-eclipse-plugin/eclipse-mojo.html

  

<强>蚀:蚀

     

全名:org.apache.maven.plugins:maven-eclipse-plugin:2.8:eclipse

     

描述的:   生成以下eclipse配置文件:

     
      
  • .project和.classpath files
  •   具有项目特定编译器设置的
  • .setting / org.eclipse.jdt.core.prefs
  •   
  • WTP(Web Tools Project)的各种配置文件,如果参数wtpversion设置为有效版本(默认情况下不生成WTP配置)
  •   
     

如果在多项目根目录上运行此目标,则模块之间的依赖关系将配置为Eclipse中的直接项目依赖项(除非将useProjectReferences设置为false)。