Eclipse,导入maven多模块项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46011947/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse, import maven multi-module project
提问by Tuomas Toivonen
How do I properly import maven multi-module project into eclipse? When I import new maven project and select the parent pom, I can see the submodules under the parent pom and they are visible in package explorer and project explorer. However, they are presented as deep directory structure, as if eclipse doesn't know they are java projects.
如何将 maven 多模块项目正确导入到 eclipse 中?当我导入新的 maven 项目并选择父 pom 时,我可以看到父 pom 下的子模块,它们在包资源管理器和项目资源管理器中可见。但是,它们以深层目录结构呈现,就好像 eclipse 不知道它们是 java 项目一样。
When I expand the submodule project, I don't see the java packages shortcuts as I would have opened a single maven project. I only see it as a deep directory structure. How do I import multimodule maven project and open the submodule project to take advantage of eclipse java project features?
当我展开子模块项目时,我没有看到 java 包快捷方式,因为我会打开一个 Maven 项目。我只将其视为深层目录结构。如何导入多模块 maven 项目并打开子模块项目以利用 eclipse java 项目功能?
回答by Black.Hyman
- Install M2E Plugin from Market if it is not already installed
- From Eclipse IDE choose "File" and "Import" from toolbar. That should lead you to a pop up.
- Type "Existing Maven Project", or navigate to this voice under Maven settings.
- Then select main pom project from the import menu, and be sure to select entire tree of projects under it.
- 如果尚未安装,请从 Market 安装 M2E 插件
- 在 Eclipse IDE 中,从工具栏中选择“文件”和“导入”。这应该会导致您弹出一个窗口。
- 键入“Existing Maven Project”,或导航到 Maven 设置下的此语音。
- 然后从导入菜单中选择主 pom 项目,并确保选择其下的整个项目树。
Before to approach this clean the IDE from current wrong imported project deleting its maven root pom project and every sub modules, but leave them in the disk obviously. I don't recommend the "Convert" options as sometimes doesn't lead to clean results, especially with big and messy projects. That should do the trick. Let me know if this solves your problem.
在从当前错误导入的项目中清除 IDE 之前,删除其 maven root pom 项目和每个子模块,但显然将它们留在磁盘中。我不推荐“转换”选项,因为有时不会产生干净的结果,尤其是对于大而杂乱的项目。这应该够了吧。如果这能解决您的问题,请告诉我。
回答by Anshu Kumar
回答by Rayen Rejeb
For everyone who still have the same issue, follow these steps:
对于仍然有相同问题的每个人,请按照以下步骤操作:
- Open
Import Existing Maven Project
wizard - Select the Parent
POM.xml
only and clickFinish
- Foreach child project,
Right Click
on the project folder, then click onImport
and select hisPOM.xml
file
- 打开
Import Existing Maven Project
向导 POM.xml
仅选择父级并单击Finish
- Foreach子项目,
Right Click
在项目文件夹上,然后点击Import
并选择他的POM.xml
文件
Hope it helps ! Good Luck !
希望能帮助到你 !祝你好运 !
回答by Guru
To add a few on top of Black Hyman's answer, ensure that the parent pom in the root of the directory that contains sub-projects, contains a modules section:
要在 Black Hyman 的答案之上添加一些内容,请确保包含子项目的目录根目录中的父 pom 包含一个模块部分:
<modules>
<module>module1</module>
<module>module2</module>
<module>module3</module>
</modules>
So, after the import, unline IntelliJ, Eclipse opens the sub-modules as separate projects, apart from the main root project.
因此,在导入之后,取消 IntelliJ,Eclipse 将子模块作为单独的项目打开,除了主根项目。
Hope this helps!
希望这可以帮助!
回答by Ahmad Hoghooghi
Step 1
第1步
- Navigate to project folder.
- Open command prompt (or shell)
- Run
mvn eclipse:eclipse
- 导航到项目文件夹。
- 打开命令提示符(或 shell)
- 跑
mvn eclipse:eclipse
Step 2
第2步
- Open eclipse IDE
- Open project from
File > Open Projects From File System...
- Select folder of project containing parent
pom.xml
file
- 打开日食IDE
- 从打开项目
File > Open Projects From File System...
- 选择包含父
pom.xml
文件的项目文件夹
Step 3
第 3 步
- Run
Project > Clean
from Menu
Project > Clean
从菜单运行
Step 4
第四步
- Run
File> Restrat
From Menu
File> Restrat
从菜单运行
Solved my problem in Eclipse 2019-06(4.12.0) and 2018-12(4.10.0)
解决了我在 Eclipse 2019-06(4.12.0) 和 2018-12(4.10.0) 中的问题
回答by CHiRAG
Follow the steps
按照步骤
- Choose file menu
- Click on
import
- Select project right click then Convert --> Convert to maven project
- Click on
import
then type or selectExisting Maven Project
- 选择文件菜单
- 点击
import
- 选择项目右键单击然后转换 --> 转换为 maven 项目
- 单击
import
然后键入或选择Existing Maven Project
Now your moduled project in you workbench. If you have any query we can discuss.
现在您的工作台中的模块化项目。如果您有任何疑问,我们可以讨论。