Eclipse 和 Maven 多模块项目的问题

发布于 2024-09-05 07:22:34 字数 880 浏览 4 评论 0原文

我创建了一个具有以下结构的 Maven 项目:

+ root-project
  pom.xml (pom)
  + sub-projectA (jar)
  + sub-projectB (jar)

我已完成以下步骤:

  1. mvn archetype:create –DgroupId=my.group.id –DartifactId=root-project
  2. mvn archetype:create –DgroupId=my.group.id –DartifactId =sub-projectA
  3. mvn archetype:create –DgroupId=my.group.id –DartifactId=sub-projectB

所以,显然,我在顶级 pom.xml 中有以下元素:

  <modules>
    <module>sub-projectA</module>
    <module>sub-projectB</module>
  </modules>

最后一步是:

mvn eclipse:clean eclipse:eclipse

现在如果我导入root-project 在 Eclipse 中,它似乎将我的项目视为资源而不是像 java 项目。

但是,如果我导入每个子项目 sub-projectAsub-projectB,它们看起来就像 java 项目。

这对我来说是一个大问题,因为我有更深的层次结构。任何帮助将不胜感激!

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:

  1. mvn archetype:create –DgroupId=my.group.id –DartifactId=root-project
  2. mvn archetype:create –DgroupId=my.group.id –DartifactId=sub-projectA
  3. mvn archetype:create –DgroupId=my.group.id –DartifactId=sub-projectB

So I have, obviously, in the top-level pom.xml the following elements:

  <modules>
    <module>sub-projectA</module>
    <module>sub-projectB</module>
  </modules>

The last step was:

mvn eclipse:clean eclipse:eclipse

Now if I import the root-project in Eclipse, it seems to look at my projects as resources and not like java projects.

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

少女情怀诗 2024-09-12 07:22:34

maven eclipse 插件不支持嵌套项目,因此您无法导入根项目和嵌套模块(除非您移动到 ​​平面布局)。

另一种方法是使用 m2eclipse (对于 Maven 典型的嵌套树,您不会遇到任何问题)。这是当今的首选方法。

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).

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.

残月升风 2024-09-12 07:22:34

请按照以下简单步骤配置项目

  1. 下载项目maven项目

  2. 在 ch-multi-spring->simple-parent 内部

使用此命令将 simple-parent 转换为 eclipse 项目

mvn eclipse:eclipse
  1. Import Eclipse 中的示例父级。

  2. 用于运行此项目

    右键单击simple-webapp->属性->部署程序集->项目->
    然后添加所有依赖的项目。

  3. 现在您可以运行该项目了。

Please follow these simple step's to configure project

  1. Download project from maven project

  2. Inside ch-multi-spring->simple-parent

convert simple-parent to eclipse project using this command

mvn eclipse:eclipse
  1. Import sample-parent in eclipse.

  2. For runing this project

    right click on simple-webapp->properties->deployment assemblly->project->
    Then add all the dependent project.

  3. Now you can run this project.

和我恋爱吧 2024-09-12 07:22:34

我遇到了类似的问题,以下是我为解决该问题所做的操作...

我打开了父项目以及子项目。子项目将构建良好并且不会显示任何问题,但是父项目将子项目显示为“资源文件夹”并且它们显示有问题。

解决方案是右键单击父项目中的每个子项目 ->属性->资源->检查“派生”

后,清理/重建,你应该是好的。

I had a similar issue, and the following is what I did to solve it...

I had the parent project open as well as the child projects. The child projects would build fine and not show any problems, however the parent showed the child projects as "resource folders" and they showed as having problems.

Solution was to right click on each of the child projects in the parent project -> Properties -> Resource -> Check "derived"

After you do this, clean/rebuild and you should be good.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文