Eclipse和Maven多模块项目的问题 [英] Problem with Eclipse and a Maven multi-module project
问题描述
我已经创建了一个具有以下结构的Maven项目:
I have created a Maven project with the following structure:
+ root-project
pom.xml (pom)
+ sub-projectA (jar)
+ sub-projectB (jar)
我已经完成了以下步骤:
I have done the following steps:
- mvn archetype:create -DgroupId = my.group.id -DartifactId = root-project
- mvn archetype:create -DgroupId = my.group.id -DartifactId = sub-projectA
- mvn archetype:create -DgroupId = my.group.id -DartifactId = sub-projectB
显然,在顶级的pom.xml中有以下元素:
So I have, obviously, in the top-level pom.xml the following elements:
<modules>
<module>sub-projectA</module>
<module>sub-projectB</module>
</modules>
最后一步是:
mvn eclipse:clean eclipse:eclipse
现在如果我导入根项目在Eclipse中,似乎将我的项目看作是资源而不是java项目。
Now if I import the root-project in Eclipse, it seems to look at my projects as resources and not like java projects.
但是,如果我导入每个子项目子项目A 和子项目B ,它看起来像java项目。
However if I import each of child projects sub-projectA and sub-projectB, it looks them like java projects.
这是一个很大的问题因为我有一个更深层次的层次。任何帮助将不胜感激!
This is a big problem for me because I have a deeper hierarchy. Any help would be appreciated!
推荐答案
maven eclipse插件不支持嵌套项目,因此您无法导入根项目和嵌套模块(除非您转到平面布局)。
The maven eclipse plugin does NOT support nested projects so you can't import the root-project and the nested modules (unless you move to a flat layout).
另一种方法是使用 m2eclipse (而且你不会有一个maven典型的嵌套树有任何问题)。这是现在的首选方法。
The alternative is to use m2eclipse (and you won't have any problems with a maven-typical nested tree). This is the preferred approach nowadays.
这篇关于Eclipse和Maven多模块项目的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!