Eclipse source out of sync with file system

2020-02-20 06:45发布

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?

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.

标签: java eclipse
10条回答
冷血范
2楼-- · 2020-02-20 07:35

just refreshing isnt always the 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

  • 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

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.

I solved this by updating all references in the org.eclipse.wst.common.component file in each project to suit their correct project

** the suffix I chose upon import, it has no particular significance

查看更多
Ridiculous、
3楼-- · 2020-02-20 07:36

By default, 'F5' on a highlighted resource will also refresh it.

查看更多
何必那么认真
4楼-- · 2020-02-20 07:36

Just remove all projects from eclipse workspace and Re-Import the all projects again. It is working for me. Just try it

查看更多
The star\"
5楼-- · 2020-02-20 07:40

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

查看更多
登录 后发表回答