[英]Import Maven multi-module project into Eclipse
How do I properly import Maven multi-module project into Eclipse?如何将 Maven 多模块项目正确导入 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.
当我导入新的 Maven 项目并选择父 pom 时,我可以看到父 pom 下的子模块,它们在包资源管理器和项目资源管理器中可见。 However, they are presented as deep directory structure, as if eclipse doesn't know they are Java projects.
但是,它们以深层目录结构呈现,就好像 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.当我展开子模块项目时,我没有看到 Java 包快捷方式,因为我会打开一个 Maven 项目。 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?
如何导入多模块 Maven 项目并打开子模块项目以利用 Eclipse Java 项目功能?
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.在从当前错误导入的项目中清除 IDE 之前,删除其 maven root pom 项目和每个子模块,但显然将它们留在磁盘中。 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.
如果这能解决您的问题,请告诉我。
For everyone who still have the same issue, follow these steps:对于仍然有相同问题的每个人,请按照以下步骤操作:
Import Existing Maven Project
wizardImport Existing Maven Project
向导POM.xml
only and click Finish
POM.xml
并单击Finish
Right Click
on the project folder, then click on Import
and select his POM.xml
file Right Click
项目文件夹,然后单击Import
并选择他的POM.xml
文件Hope it helps !希望它有帮助! Good Luck !
祝你好运!
mvn eclipse:eclipse
mvn eclipse:eclipse
File > Open Projects From File System...
File > Open Projects From File System...
pom.xml
filepom.xml
文件的项目文件夹Project > Clean
from MenuProject > Clean
从菜单Project > Clean
File> Restrat
From MenuFile> Restrat
从菜单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) 中的问题
When you start to search for files in 'open resource' (for example using Ctrl
+ Shift
+ R
) eclipse will show file from two address.当您开始在“打开资源”中搜索文件时(例如使用
Ctrl
+ Shift
+ R
),eclipse 将显示来自两个地址的文件。 for example MySampleFile
will be available under:例如
MySampleFile
将在以下位置可用:
parent-module/sub-module/src/main/java/.../MySampleFile
and parent-module/sub-module/src/main/java/.../MySampleFile
和sub-module/src/main/java/.../MySampleFile
Use second one .使用第二个。 Opening file with first one will not activate IDE features on that file.
使用第一个打开文件不会激活该文件的 IDE 功能。
First, import the parent project.首先,导入父项目。 Then, right click on it at the package/project explorer, go to Configure and then click the Configure and Detected Nested Projects... , on the window that will appear click Finish and you're gold.
然后,在包/项目资源管理器中右键单击它,转到“配置” ,然后单击“配置和检测到的嵌套项目...” ,在出现的窗口中单击“完成” ,您就成功了。
Also worth mentioning, Package Explorer won't show it nested, use Project Explorer instead.还值得一提的是,Package Explorer 不会显示嵌套,而是使用 Project Explorer。
Have a nice day.有一个美好的一天。
To add a few on top of Black Jack's answer, ensure that the parent pom in the root of the directory that contains sub-projects, contains a modules section:要在 Black Jack 的答案之上添加一些内容,请确保包含子项目的目录根目录中的父 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!希望这有帮助!
Follow the steps按照步骤操作
import
import
import
then type or select Existing Maven Project
import
然后键入或选择Existing Maven Project
Now your moduled project in you workbench.现在您的工作台中的模块化项目。 If you have any query we can discuss.
如果您有任何疑问,我们可以讨论。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.