Java 将现有项目导入 Eclipse 时,Maven 根 pom.xml 标记为红色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30000107/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 08:56:47  来源:igfitidea点击:

Maven root pom.xml marked as red when importing existing project into eclipse

javaeclipsemavenimportparent-pom

提问by zalis

When importing existing maven project into eclipse my root pom.xml is marked red. when i select on the pom.xml the message reads :

将现有的 maven 项目导入 eclipse 时,我的根 pom.xml 被标记为红色。当我在 pom.xml 上选择时,消息显示:

Can't import project XYZ from an existing workspace folder

无法从现有工作区文件夹导入项目 XYZ

This only happens for the root pom.xml

这只发生在根 pom.xml

Eclipse in use: Luna Service Release 2 (4.4.2) Maven Integration for Eclipse 1.5.2.20150413-2215

正在使用的 Eclipse:Luna Service Release 2 (4.4.2) Maven Integration for Eclipse 1.5.2.20150413-2215

I have tested with number of different maven projects and in different workspaces.

我已经在不同的工作空间中测试了许多不同的 Maven 项目。

Please note this worked before, I have been working on some tutorials and created number of Maven projects with same name and artifact Ids etc. I have deleted all the earlier projects, but could there still be some conflicts ?

请注意,这之前有效,我一直在研究一些教程,并创建了许多具有相同名称和工件 ID 等的 Maven 项目。我已经删除了所有早期的项目,但仍然会存在一些冲突吗?

any suggestions will help

任何建议都会有所帮助

采纳答案by chirag28feb

Yes, You should start your Eclipse Workspace out of the pom.xml folder.

是的,您应该从 pom.xml 文件夹中启动您的 Eclipse 工作区。

for example: D:\workspace\Project_Name.

例如:D:\workspace\Project_Name

In your Project_Namefolder which contains pom.xml.

在您的Project_Name文件夹中,其中包含pom.xml.

So you have to select D:\workspacewhile starting the eclipse.

所以你必须D:\workspace在开始日食时选择。

And now, then import the project called Project_Nameas maven project, It will work.

现在,然后导入名为Project_Namemaven 项目的项目,它将起作用。

Hope, it will help !!

希望,它会有所帮助!

回答by gubs

I also came across this same issue. I kept my eclipse workspace name and existing maven project name same and got the error importing pom.xml. Later i opened new workspace with different name which is not matching to the existing maven project and now i could import maven project.

我也遇到了同样的问题。我保持我的 eclipse 工作区名称和现有的 maven 项目名称相同,但在导入 pom.xml 时出现错误。后来我用不同的名称打开了新的工作区,它与现有的 maven 项目不匹配,现在我可以导入 maven 项目。

回答by Souvik Shaw

Solution:

解决方案:

1.Click on Windows tab then Preference(if you are using Eclipse).

1.单击 Windows 选项卡,然后单击首选项(如果您使用的是 Eclipse)。

2.Search for the Workspaces first and remove all of them from list(which you can add later eventually)

2.首先搜索工作区并从列表中删除所有它们(您可以稍后添加)

3.Then search for Maven and choose User Setting and check your .m2 path along with the updated setting.xml(meanwhile check the proxy too)

3.然后搜索Maven并选择用户设置并检查您的.m2路径以及更新的setting.xml(同时检查代理)

4.After that restart your eclipse and import the existing maven project again.

4.之后重启你的eclipse并再次导入现有的maven项目。

I'm 100% percent sure u'll no longer face this issue after that. Good Luck :)

我 100% 确定在那之后你将不再面临这个问题。祝你好运 :)