如何在 Eclipse 中更改项目的位置指针?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16739771/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 21:43:28  来源:igfitidea点击:

How can I change a project's location pointer in Eclipse?

eclipsedirectorylocationprojecttarget

提问by Redsandro

A project has moved to a different location, so Eclipse won't open the project. You'll immediately think about simply changing the pointer to the location, but in Eclipse they try to make this impossible for some reason.

项目已移至其他位置,因此 Eclipse 不会打开该项目。您会立即考虑简单地更改指向该位置的指针,但在 Eclipse 中,由于某种原因,他们试图使这成为不可能。

You cannot change the project location in the Project Explorerproperties.

您不能在Project Explorer属性中更改项目位置。

You can go to [workspace]/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/ProjectNameand try to edit .locationwhich is the pointer to the project, but this file is purposely stored in binary.

你可以去[workspace]/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/ProjectName尝试编辑.location哪个是指向项目的指针,但这个文件是故意以二进制形式存储的。

How do I change this .location, is there a tool for that? Any other way to simplypoint my old project entry to it's new location?

我该如何更改它.location,是否有相应的工具?还有其他方法可以简单地将我的旧项目条目指向它的新位置吗?

回答by Kai

Delete the project from eclipse.

从 Eclipse 中删除项目。

ENSURE THAT THE CHECK BOX is UNSELECTED, during this delete

确保在删除过程中未选中复选框

And then import the project by File-> Import-> Import existing projectand choose it from the new location.

然后通过File-> Import->导入项目Import existing project并从新位置选择它。

Don'ttry to modify the eclipse files manually!

不要尝试手动修改 eclipse 文件!

回答by kerner1000

Much more simple:

更简单:

Right click-> Refactor-> Move

右键单击->重构->移动

.

.

回答by hamidreza maddah

You can go to [workspace]/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/ProjectName and try to edit .location which is the pointer to the project, but this file is purposely stored in binary. You Should Edit the location in file and some binary data ] the binary data that should edit , is bold :

您可以转到 [workspace]/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/ProjectName 并尝试编辑指向项目的指针 .location,但此文件特意以二进制形式存储. You should Edit the location in file and some binary data] 要编辑的二进制数据,粗体:

40 B1 8B 81 23 BC 00 14 1A 25 96 E7 A3 93 BE 1E 00 5D55 52 49 2F 2F 66 69 6C 65 3A 2F 44 3A 2F 6D 61 64 64 61 68 2F 50 72 6F 6A 65 63 74 73 2F 46 6C 65 65 74 4D 61 6E 61 67 65 6D 65 6E 74 2F 54 79 70 65 73 2F 50 6F 72 74 61 62 6C 65 63 6F 64 65 2F 46 69 72 6D 77 61 72 65 2F 74 65 73 74 2F 43 50 50 2F 41 54 6D 65 61 67 38 4C 69 6200 00 00 00 00 00 00 00 00 00 00 00 00 00 C0 58 FB F3 23 BC 00 14 1A 51 F3 8C 7B BB 77 C6

40 B1 8B 81 23 BC 00 14 1A 25 96 E7 A3 93 BE 1E 00 5D55 52 49 2F 2F 66 69 6C 65 3A 2F 44 3A 2F 6D 61 64 64 61 68 2F 50 72 6F 6A 65 63 74 73 2F 46 6C 65 65 74 4D 61 6E 61 67 65 6D 65 6E 74 2F 54 79 70 65 73 2F 50 6F 72 74 61 62 6C 65 63 6F 64 65 2F 46 69 72 6D 77 61 72 65 2F 74 65 73 74 2F 43 50 50 2F 41 54 6D 65 61 67 38 4C 69 6200 00 00 00 00 00 00 00 00 00 00 00 00 00 C0 00 00 F C0 3085 1B 4 B C0 5 3 7 7 B C 3 0 8 7 7 B C 3 0 00 5D00 00

The Location of 0x11 of file, is the length of file name, that you should edit it. its value is the length of highlighted part

文件0x11的位置,是文件名的长度,你应该编辑它。它的值是突出显示部分的长度

Also You Can Use ProjectLocationUpdater : https://marketplace.eclipse.org/content/projectlocationupdater/metrics

您也可以使用 ProjectLocationUpdater :https: //marketplace.eclipse.org/content/projectlocationupdater/metrics

回答by David Hirst

I realise this is an old post however I thought I would add my own resolution to the same issue. I had imported a number of projects into my workspace from another machine. However the resource files would not build because for some reason Eclipse had marked the location of the projects incorrectly (using a mapped path instead of a unc path). This meant that each time I tried to reference libraries within the workspace they would tick green, then go red and fail. Despite the fact the libraries and the project where in the same workspace and I had followed the correct procedure for importing the projects.

我意识到这是一个旧帖子,但我想我会在同一问题上添加我自己的解决方案。我已经从另一台机器将一些项目导入到我的工作区中。然而,资源文件不会构建,因为出于某种原因 Eclipse 错误地标记了项目的位置(使用映射路径而不是 unc 路径)。这意味着每次我尝试在工作区中引用库时,它们都会勾选绿色,然后变为红色并失败。尽管库和项目在同一个工作区中,但我遵循了导入项目的正确程序。

As the OP mentions under properties there is a project location path. I noticed that the project location was different but for some bizarre reason Eclipse (in their almighty wisdom) do not allow you to reselect or change the path. In fact even trying the refactor->move fails because the project is already inside the workspace (never heard of generating a temp folder for moves?).

正如 OP 在属性下提到的,有一个项目位置路径。我注意到项目位置不同,但出于某种奇怪的原因,Eclipse(以其全能的智慧)不允许您重新选择或更改路径。事实上,即使尝试 refactor->move 也会失败,因为该项目已经在工作区中(从未听说过为移动生成临时文件夹?)。

However I did notice after looking at the file structure of the imported projects that Eclipse had added a .location file (mentioned above) which was actually absent from all other projects in the workspace. So I deleted the .location file, reopened eclipse and sure enough the projects build properly.

但是,在查看导入项目的文件结构后,我确实注意到 Eclipse 添加了一个 .location 文件(如上所述),该文件实际上在工作区中的所有其他项目中都没有。所以我删除了 .location 文件,重新打开了 eclipse,果然项目构建正确。

So after wasting a few hours on something as silly as this I am now able to work and hopefully this might save you some trouble too.

因此,在像这样愚蠢的事情上浪费了几个小时之后,我现在可以工作了,希望这也可以为您省去一些麻烦。

回答by bsumirak

You can change the .location file using a hex editor. However, you cannot simply replace the file location string stored there by the new one. You also have to edit the preceding byte defining its length (in bytes) accordingly. You may then re-open the project in Eclipse.

您可以使用十六进制编辑器更改 .location 文件。但是,您不能简单地用新的替换存储在那里的文件位置字符串。您还必须相应地编辑定义其长度(以字节为单位)的前一个字节。然后您可以在 Eclipse 中重新打开该项目。

回答by Jorge Moraleda

Summary of what worked for me (Extracted from other answers and comments)

对我有用的总结(摘自其他答案和评论)

1 (Only required if you have already moved the project)

1(仅当您已经移动项目时才需要)

make symlink to the new location from the old location.

2 Regardless of the type of project (Java, Python, etc.)

2 无论项目类型(Java、Python 等)

Open view Package Explorer (Window -> Show View -> Other -> Java -> Package Explorer)
Right click -> Refactor -> Move (in the relevant project within that Package Explorer)
Select new location

3 (If a symlink was created)

3(如果创建了符号链接)

Delete symlink if one was created in step 1

回答by jaogoy

It is not advisable to change the .location file. The eclipse project list will be destroyed if you manually edit the .location file. I lost all the projects after modifying the file.

不建议更改 .location 文件。如果手动编辑 .location 文件,eclipse 项目列表将被破坏。修改文件后我丢失了所有项目。

回答by reverb1010

Admittedly, this is a dated post, but I wanted to mention that I faced this same issue using Spring Tool Suite 3.9.7 when I was pushing my project to a new Github repo and something went terribly awry. As a result, I could not run my application locally anymore and had to revert the project location. I had read horror stories about git deleting project files, so I did some research. For the most part, I went with the answer of @kerner1000 above, but with an important addition. Please see below steps and explanation.

诚然,这是一篇过时的帖子,但我想提一下,当我将我的项目推送到新的 Github 存储库时,我在使用 Spring Tool Suite 3.9.7 时遇到了同样的问题,并且出现了严重的错误。结果,我无法再在本地运行我的应用程序,不得不恢复项目位置。我读过关于 git 删除项目文件的恐怖故事,所以我做了一些研究。在大多数情况下,我采用了上面@kerner1000 的答案,但还有一个重要的补充。请参阅以下步骤和说明。

  • Rt. click on the project
  • select "Refactor"
  • select "Move..."
  • Checkthe checkbox for, "Use default location"
  • Rt。点击项目
  • 选择“重构”
  • 选择“移动...”
  • 选中“使用默认位置”复选框

Note: I tried at first to copy/paste in the path to relocate the project to, but Eclipse gave me an over-write error. So checking the checkbox made the difference.

注意:我首先尝试复制/粘贴路径以将项目重新定位到,但是 Eclipse 给了我一个覆盖错误。因此,选中复选框会有所不同。

回答by demongolem

I was working in PyDev (python) and this refactor option was not available. I had to switch to the Java Package Manager to accomplish this. After doing that, I switched back to PyDev.

我在 PyDev (python) 中工作,但此重构选项不可用。我不得不切换到 Java 包管理器来完成这个。这样做之后,我切换回 PyDev。

回答by Waseem

Try this. Open eclipse --> Go to File --> switch workspace --> other --> choose your workspace by clicking the Browse button. Hope this will work.

尝试这个。打开 eclipse --> 转到文件 --> 切换工作区 --> 其他 --> 通过单击浏览按钮选择您的工作区。希望这会奏效。