Java Eclipse 源与文件系统不同步
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6626703/
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 source out of sync with file system
提问by Belmiris
I inherited a java project and don't have much experience with Eclipse. In the package explorer I can see the outline of the project with all the classes but when I try to edit any of them it says the source code is not found. When I look the source code is where it seems it is supposed to be. I am assuming that in pulling the code out of source control the path must have changed from the original. Is there an easy way to tell the IDE to just connect a code file to a class?
我继承了一个 java 项目,对 Eclipse 没有太多经验。在包资源管理器中,我可以看到包含所有类的项目大纲,但是当我尝试编辑它们中的任何一个时,它说找不到源代码。当我查看源代码时,它似乎应该在那里。我假设在将代码从源代码管理中拉出时,路径必须与原始路径有所不同。有没有一种简单的方法可以告诉 IDE 将代码文件连接到一个类?
What's really weird is that 'some' of the files in the very same directory are found while others are not. Can't say I think very highly of this IDE so far.
真正奇怪的是,在同一目录中找到了“某些”文件,而其他文件则没有。到目前为止,我不能说我对这个 IDE 的评价很高。
采纳答案by Jim Garrison
Right click on the project in the Package Explorer view and select Refresh.
在 Package Explorer 视图中右键单击该项目并选择 Refresh。
回答by bvulaj
By default, 'F5' on a highlighted resource will also refresh it.
默认情况下,突出显示的资源上的“F5”也会刷新它。
回答by Basanth Roy
You can right click on the project name and click refresh. And just to be sure, you can select the package name and right click 'Refresh' too.
您可以右键单击项目名称,然后单击刷新。并且可以肯定的是,您也可以选择包名称并右键单击“刷新”。
回答by Kounavi
You can have Eclipse do that automatically for you.
您可以让 Eclipse 自动为您执行此操作。
Using the latest version, go to Window -> Preferences.
使用最新版本,转到窗口 -> 首选项。
Select General -> Workspace and from there make sure the first and second option are checked:
选择 General -> Workspace 并确保选中第一个和第二个选项:
- Build automatically
- Refresh using native hooks or polling
- 自动构建
- 使用本机钩子或轮询刷新
This is very useful especially if you use Dropbox or something similar (wuala etc) :)
这非常有用,特别是如果您使用 Dropbox 或类似的东西(wuala 等):)
回答by Vinoj John Hosan
- Right click on the project in the Package Explorer view and select Refresh. If it is not working,
- Clean the project... project menu -> clean... and refresh
- 在 Package Explorer 视图中右键单击该项目并选择 Refresh。如果它不起作用,
- 清理项目...项目菜单 -> 清理...并刷新
回答by Akmal Azlan
Click on the project, then press F5 to refresh the file. It should be fine.
单击项目,然后按 F5 刷新文件。应该没问题。
回答by Riverside
If refresh and clean doesn't work, it might work to just simply just run your code. For me it did the trick. After many refresh and cleaning/ building didn't work.
如果 refresh 和 clean 不起作用,它可能只是简单地运行您的代码。对我来说,它成功了。经过多次刷新和清洁/建筑不起作用。
回答by Ganesa Vijayakumar
Just remove all projects from eclipse workspace and Re-Import the all projects again. It is working for me. Just try it
只需从 eclipse 工作区中删除所有项目并再次重新导入所有项目。它对我有用。就试一试吧
回答by Ordiel
If using maven or other builder be sure that you disable the plug ins some plug ins, specially the ones meant to generate/change code will never let you be fully on sync
如果使用 maven 或其他构建器,请确保禁用某些插件的插件,特别是那些旨在生成/更改代码的插件永远不会让您完全同步
回答by bigbadmouse
just refreshing isnt alwaysthe answer. I had this source issue happen when I had imported two projects with the same context for review and Eclipse made me disambiguate them, forcing a change to the web context of the second. The source for one was linking to the other context's source folder. eg
只是刷新并不总是答案。当我导入两个具有相同上下文的项目进行时,我遇到了这个源问题,Eclipse 使我消除了它们的歧义,强制更改了第二个的 Web 上下文。一个的源链接到另一个上下文的源文件夹。例如
- project A(in folder A1) deployed as /A
- project A(in folder A2) deployed as /A also but was forced to be /A[later**] upon import
- 项目 A(在文件夹 A1 中)部署为 /A
- 项目 A(在文件夹 A2 中)也部署为 /A,但在导入时强制为 /A[later**]
in .settings/org.eclipse.wst.common.component
(within folder A1) the wb-module
element referred to the other context /A[later] and was using its source code, not that for /A.
在.settings/org.eclipse.wst.common.component
(文件夹 A1 内)中,该wb-module
元素引用了另一个上下文 /A[later] 并且正在使用其源代码,而不是 /A 的源代码。
I solved this by updating all references in the org.eclipse.wst.common.component
file in each project to suit their correct project
我通过更新org.eclipse.wst.common.component
每个项目中文件中的所有引用来解决这个问题以适合他们正确的项目
** the suffix I chose upon import, it has no particular significance
**导入时选择的后缀,没有特别的意义