Eclipse 缺少已导入的所需项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6871205/
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
Eclipse missing already imported required project
提问by tb189
I have 3 java projects in eclipse (A, B, C), where C is a required project for both A and B. Each time I start eclipse, I get the error
我在eclipse(A,B,C)中有3个java项目,其中C是A和B的必需项目。每次启动eclipse时,我都会收到错误
Project 'A' is missing required Java project: 'C'
Project 'B' is missing required Java project: 'C'
When I remove project C from the build path of A or B, and add it again, the error disappears. The errors ... cannot be resolved to a type
only appear when I remove project C from the build path, and F3-ing to source files in project C from project A or B works, implying that it does find the correct source files.
当我从 A 或 B 的构建路径中删除项目 C 并再次添加时,错误消失了。... cannot be resolved to a type
只有当我从构建路径中删除项目 C 时才会出现错误,并且从项目 A 或 B 中 F3 到项目 C 中的源文件有效,这意味着它确实找到了正确的源文件。
My .classpath file looks like this:
我的 .classpath 文件如下所示:
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/JCIFS"/>
<classpathentry combineaccessrules="false" kind="src" path="/C"/>
<classpathentry kind="output" path="bin"/>
</classpath>
My eclipse version is Galileo, plug-ins: Subclipse, CDT (so no Maven). Build automatically is checked.
我的eclipse版本是Galileo,插件:Subclipse、CDT(所以没有Maven)。自动构建被选中。
Anybody know how I can avoid re-adding the project every time I start eclipse?
有人知道如何避免每次启动 eclipse 时都重新添加项目吗?
采纳答案by gotomanners
Try this:
尝试这个:
- Right click on your project name (A or B) and select properties...
- Select Java Build Path and the Projects tab, check project C as a required project on each of A and B.
- Select the "Project References" option and check project C as a project reference on each of A and B.
- Clean and rebuild just for the craic!
- Make sure Project C is not closed when eclipse is restarted.
- 右键单击您的项目名称(A 或 B)并选择属性...
- 选择 Java Build Path 和 Projects 选项卡,检查项目 C 作为 A 和 B 上的必需项目。
- 选择“项目引用”选项并检查项目 C 作为 A 和 B 中的每一个的项目引用。
- 清洁和重建只是为了疯狂!
- 确保重新启动 eclipse 时未关闭 Project C。
回答by Daniel Winterstein
I've seen this too, and on several occasions though with no clear pattern. I believe it is a bug in Eclipse.
我也看到过这种情况,并且在很多情况下都没有看到过清晰的模式。我相信这是 Eclipse 中的一个错误。
Sometime closing & re-opening project A fixes it. Sometimes I have to delete & re-install Eclipse to fix it.
有时关闭并重新打开项目 A 修复它。有时我必须删除并重新安装 Eclipse 才能修复它。
回答by z0r
I just had this too, and I think it was because of a resource filter. I was trying to hide .class files from the open resource dialogue. To fix this problem, I removed my resource filter and cleaned the projects - now it seems to be behaving well.
我也有这个,我认为这是因为资源过滤器。我试图从打开的资源对话框中隐藏 .class 文件。为了解决这个问题,我删除了我的资源过滤器并清理了项目 - 现在它似乎表现良好。
回答by dunni
Have you simply tried to clean your workspace and do a full build?
您是否只是尝试清理工作区并进行完整构建?
回答by Aaron Digulla
This error typically happens if the project is closed. But you would get the error as soon as you close C - that is, long before you restart Eclipse.
如果项目关闭,通常会发生此错误。但是,一旦关闭 C,您就会收到错误消息——也就是说,在您重新启动 Eclipse 之前很久。
It's quite hard to say what could cause this. Mabye it's an old bug but I don't remember anything specifically in 3.5 / Galileo.
很难说是什么导致了这种情况。Mabye 这是一个旧错误,但我不记得 3.5/Galileo 中的任何内容。
Try these things:
试试这些:
- "Clean..." and select all projects. Does that help?
- When you get the error, did Eclipse succeed or fail to build C?
- Is that a Java or C/C++ project? Maybe it's a bug in CDT.
- Try with Eclipse 3.7. It's pretty compatible with 3.5 but many bugs were fixed. Maybe that fixes your issue, too. Export your prefs, unpack 3.7 somewhere (leave 3.5 alone), import prefs. If you want to be 100% sure, create a second workspace.
- “清理...”并选择所有项目。这有帮助吗?
- 当您收到错误时,Eclipse 构建 C 是成功还是失败?
- 那是 Java 还是 C/C++ 项目?也许这是CDT中的一个错误。
- 尝试使用 Eclipse 3.7。它与 3.5 非常兼容,但修复了许多错误。也许这也解决了您的问题。导出您的首选项,在某处解压缩 3.7(单独保留 3.5),导入首选项。如果您想 100% 确定,请创建第二个工作区。
回答by Angel O'Sphere
This looks like a windows path names problem. Why do yo name your projects A, B, C and dont give them proper names isntead?
这看起来像一个 Windows 路径名问题。为什么你给你的项目命名为 A、B、C 而不要给它们取合适的名字?
<classpathentry combineaccessrules="false" kind="src" path="/C"/>
I would bet that /C is interpreted errornously as a drive letter, hence your problems.
我敢打赌 /C 被错误地解释为驱动器号,因此您的问题。