简体   繁体   English

Eclipse 错误:非 Maven 项目的“无法读取 maven 项目”

[英]Eclipse error: "Could not read maven project" for non-Maven project

I have a git Eclipse project that used to use Maven. I created a new Eclipse project on one computer, imported the source code, and successfully built it.我有一个git Eclipse项目,以前用的是Maven,我在一台电脑上新建了一个Eclipse项目,导入源码,构建成功。 I then committed and pushed my changes to GitHub.然后我提交并将我的更改推送到 GitHub。

When I cloned the project on another computer (OS X) and imported it, I get this error when I try building:当我在另一台计算机 (OS X) 上克隆项目并导入它时,我在尝试构建时遇到此错误:

Could not read maven project

When I click for additional details, I see:当我单击以获取更多详细信息时,我看到:

Could not read maven project
Some problems were encountered while processing the POMs:
[FATAL] Non-readable POM /Users/spertus/src/wordui/pom.xml: /Users/spertus/src/wordui/pom.xml (No such file or directory) @ 

Of course there is no pom.xml file.当然没有pom.xml文件。 I am no longer using Maven.我不再使用 Maven。

When I open the project Properties, the only item listed under Project Natures is Java.当我打开项目属性时,项目性质下列出的唯一项目是 Java。

Here is the .project file:这是.project文件:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>wordui</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
</projectDescription>

I have tried reopening Eclipse, cleaning the project, and deleting and reimporting it, to no effect.我试过重新打开Eclipse,清理项目,删除再导入,没有效果。

I don't think .classpath should matter, but here it is:我不认为.classpath应该重要,但这里是:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/javafx-jre17">
        <attributes>
            <attribute name="module" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Wordnik API"/>
    <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/JavaFX 17"/>
    <classpathentry kind="output" path="bin"/>
</classpath>

I am using Eclipse for Java Developers 2022-03.我正在为 Java Developers 2022-03 使用 Eclipse。 The run configuration is under Java Application.运行配置在 Java Application 下。

I was not able to fix the problem, but I was able to work around it by:我无法解决问题,但可以通过以下方式解决:

  1. Creating a brand new Java project.创建一个全新的 Java 项目。
  2. Importing the old source code.导入旧的源代码。
  3. Adding the libraries.添加库。
  4. Running with the default run configuration.使用默认运行配置运行。

In other words, if you get to this state, create a new project.也就是说,如果你到了这个state,就新建一个项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM