简体   繁体   English

Java构建路径中缺少项目 - 项目设置

[英]Missing Project in the Java Build Path - Projects settings

There are two java projects imported into Eclipse workspace: 导入Eclipse工作区的两个java项目:

  • MainProject
  • SecondProject

The MainProject is required on the build path of the SecondProject . MainProject的构建路径上需要SecondProject

Before I have migrated the source code of both projects to our Team Foundation Server , the MainProject was referenced in the properties of the SecondProject via the "Java Build Path" -> "Projects" tab. 之前,我已经迁移这两个项目对我们的源代码Team Foundation Server ,该MainProject是在的属性引用SecondProject"Java Build Path" -> "Projects"选项卡。 And everything worked fine. 一切都很好。

Now, after both projects were imported from TFS to a clean Eclipse workspace via Team Explorer Everywhere plugin, the MainProject project is no longer visible on the "Projects" tab and in the "Add..." button dialog. 现在,在通过Team Explorer Everywhere插件将两个项目从TFS导入到干净的Eclipse工作区之后, "Projects"选项卡和"Add..."按钮对话框中的MainProject项目不再可见。

The funny thing is that the MainProject is also not visible, for example, in the Project -> Clean... dialog but it is visible in the project properties -> "Project References" dialog... 有趣的是, MainProject也不可见,例如,在Project -> Clean...对话框中,但它在project properties -> "Project References"对话框中可见...

Where could be the problem??? 哪里可能是问题???

Eclipse version 3.6.2 (Helios SR2), TFS 2010 SP1 Eclipse版本3.6.2(Helios SR2),TFS 2010 SP1

PS If I add <classpathentry kind="src" path="/MainProject"/> to the .classpath by hand, an error "Project 'SecondProject' is missing required Java project: 'MainProject'" is shown. PS如果我<classpathentry kind="src" path="/MainProject"/><classpathentry kind="src" path="/MainProject"/>.classpath ,则会显示错误“Project'SecondProject'缺少所需的Java项目:'MainProject'”。

I may be completely wrong, but it sounds to me like Eclipse might not be seeing your imported TFS projects as "Java" projects (Eclipse also supports "plain" projects, among others). 我可能完全错了,但听起来像Eclipse可能没有将您导入的TFS项目视为“Java”项目(Eclipse也支持“普通”项目等)。 When you look at *.java files in the package hierarchy of your projects, do they have a solid-blue "J" in their respective icons or are they "hollow"? 当您查看项目的包层次结构中的* .java文件时,它们在各自的图标中是否具有纯蓝色的“J”,或者它们是“空心的”?

If the former is true, then Eclipse IS seeing your projects as Java projects, I'll be thoroughly confused, and you can ignore my answer ;) 如果前者是真的,那么Eclipse将您的项目视为Java项目,我将彻底混淆,您可以忽略我的答案;)

If the latter is true, then the project is not configured as a "Java project". 如果后者为真,那么项目不会配置为“Java项目”。 This can be a real mess to deal with... but one solution in this case could be to rename your existing projects to something else (eg MainProjectOld, SecondProjectOld), create new "MainProject" and "SystemProject" projects as new "Java" projects, then copy all the source code from the old to the new source folders. 这可能是一个真正的混乱...但在这种情况下,一个解决方案可能是将您现有的项目重命名为其他项目(例如MainProjectOld,SecondProjectOld),创建新的“MainProject”和“SystemProject”项目作为新的“Java”项目,然后将所有源代码从旧的源文件夹复制到新的源文件夹。 I don't know much about TeamFoundationServer, but I would assume at this point you could reconnect your new projects with TFS and recommit them as the Java Projects they are. 我对TeamFoundationServer了解不多,但我想在这一点上你可以用TFS重新连接你的新项目并重新将它们作为Java项目重新发布。

EDIT 编辑

Bottom line is, if the latter is true, then it sounds like the project configuration XML files didn't make it into TFS, and Eclipse is confused about how it should treat the projects (plain, Java, or otherwise) after initial import from TFS. 底线是,如果后者是真的,那么听起来就像项目配置XML文件没有进入TFS,而Eclipse在初始导入后应该如何处理项目(普通,Java或其他) TFS。 I've seen this happen in CVS and SVN as well, so I'm assuming it's a fairly common problem across any of the version control systems Eclipse supports. 我已经在CVS和SVN中看到过这种情况,所以我认为这是Eclipse支持的任何版本控制系统中相当普遍的问题。 TFS may be included in that bunch. TFS可能包含在那一堆中。

你应该确保当你从存储库中检出代码时应用程序有.project,.project可用。你应该从命令行创建.project,你的代码是'mvn eclipse:eclipse'命令,并重新启动你的eclipse 。

First go to your project root and edit .project file . make sure there have entry for javabuilder as following . If not then 
<buildCommand>
    <name>    org.eclipse.jdt.core.javabuilder    </name>
    <arguments>
    </arguments>
</buildCommand>
Full .Project file looks like.

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>Your Project </name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.wst.common.project.facet.core.builder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.wst.validation.validationbuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
        <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
        <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
        <nature>org.eclipse.jdt.core.javanature</nature>
        <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
    </natures>
</projectDescription>

我不熟悉Team Foundation Server,但如果您想在Eclipse内外构建项目,我建议使用Maven。

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

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