Java 构建路径中缺少项目 - 项目设置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9808827/
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
Missing Project in the Java Build Path - Projects settings
提问by Dime
There are two java projects imported into Eclipse workspace:
有两个 java 项目导入到 Eclipse 工作区:
MainProject
SecondProject
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. And everything worked fine.
在我将两个项目的源代码迁移到我们的 之前Team Foundation Server
,MainProject
在SecondProject
通过"Java Build Path" -> "Projects"
选项卡的属性中引用了。一切正常。
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.
现在,在TFS
通过Team Explorer Everywhere
插件将两个项目从干净的 Eclipse 工作区导入后,该MainProject
项目在"Projects"
选项卡和"Add..."
按钮对话框中不再可见。
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
P.S. 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"/>
到.classpath
手动,一个错误“项目‘SecondProject’缺少必需的Java项目:‘MainProject’”所示。
采纳答案by CodeBlind
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). 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"?
我可能完全错了,但在我看来,Eclipse 可能不会将您导入的 TFS 项目视为“Java”项目(Eclipse 还支持“普通”项目等)。当您查看项目包层次结构中的 *.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". 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 (e.g. 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. 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.
如果后者为真,则该项目未配置为“Java 项目”。这可能是一团糟处理……但在这种情况下,一个解决方案可能是将现有项目重命名为其他项目(例如 MainProjectOld、SecondProjectOld),将新的“MainProject”和“SystemProject”项目创建为新的“Java”项目,然后将所有源代码从旧的源代码文件夹复制到新的源代码文件夹。我对 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. 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. TFS may be included in that bunch.
底线是,如果后者是真的,那么听起来项目配置 XML 文件没有进入 TFS,并且 Eclipse 对在初始导入后应该如何处理项目(普通、Java 或其他)感到困惑TFS。我在 CVS 和 SVN 中也看到过这种情况,所以我假设这是 Eclipse 支持的任何版本控制系统中相当普遍的问题。TFS 可能包含在该组中。
回答by Puce
I'm not familiar with Team Foundation Server, but I recommend to use Maven if you want to build projects inside and outside of Eclipse.
我不熟悉 Team Foundation Server,但如果您想在 Eclipse 内部和外部构建项目,我建议使用 Maven。
回答by Vijay Bhatt
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>
回答by sai1979
You should make sure the application has .project, .project may not be available when you check out code from repository, You should create .project from command line in folder where your code is with 'mvn eclipse:eclipse' command and restart you eclipse.
您应该确保应用程序具有 .project,当您从存储库中检出代码时,.project 可能不可用,您应该从命令行在您的代码所在的文件夹中使用“mvn eclipse:eclipse”命令创建 .project 并重新启动您的 eclipse .