Eclipse - 重命名一个包摆脱了一堆东西,有没有办法恢复它?

时间:2022-12-03 06:11:31

So I made a package, lets call it dev.example.project for example purposes. all my other packages extended off of that one, with names like dev.example.project.handler or dev.example.project.assets. But I decided to go back and change the dev.example.project package's name to something else, like dev.betterexample.project.

所以我创建了一个包,我们称之为dev.example.project用于示例目的。我的所有其他包都扩展了那个包,名称如dev.example.project.handler或dev.example.project.assets。但我决定返回并将dev.example.project包的名称更改为其他名称,例如dev.betterexample.project。

I thought it would be a simple matter of renaming all the other packages and import statements so no errors would happen, but right after i changed the name, all the packages in my project turned white and became inaccessible. I changed the name back to what it originally was, but when i opened Eclipse again, some packages and files were simply not there.

我认为重命名所有其他包和import语句是一件简单的事情,因此不会发生错误,但在我更改名称后,我项目中的所有包都变为白色并变得无法访问。我将名称更改回原来的名称,但是当我再次打开Eclipse时,一些软件包和文件根本就不存在。

I spent a lot of time on this project, someone help?

我花了很多时间在这个项目上,有人帮忙吗?

1 个解决方案

#1


2  

Depending how exactly you did that renaming, various things could have gone wrong.

根据你重命名的确切方式,各种各样的事情都可能出错。

Remember: you can always go in and work outside of eclipse. Close it, open a file explorer and create directories that use the names you want to use. Then move files manually to their target directories. If you want to, open them in another text editor and fix the package lines. When you now open eclipse, do a refresh and full rebuild. Things should be fine then.

记住:你总是可以进入日食以外的地方工作。关闭它,打开文件资源管理器并创建使用您要使用的名称的目录。然后手动将文件移动到其目标目录。如果您愿意,可以在另一个文本编辑器中打开它们并修复包行。当你现在打开eclipse时,进行刷新和完全重建。事情应该没问题。

That is probably not the most elegant solution, but it always works. And more importantly, you are in full control of everything that happens!

这可能不是最优雅的解决方案,但它始终有效。更重要的是,您可以完全控制所发生的一切!

And for the record: the real answer to avoid catastrophic loss of code is to use a source code management system such as git. And to then push your changes constantly out to that "backup" facility.

并且为了记录:避免灾难性代码丢失的真正答案是使用源代码管理系统,如git。然后将您的更改不断推送到“备份”工具。

#1


2  

Depending how exactly you did that renaming, various things could have gone wrong.

根据你重命名的确切方式,各种各样的事情都可能出错。

Remember: you can always go in and work outside of eclipse. Close it, open a file explorer and create directories that use the names you want to use. Then move files manually to their target directories. If you want to, open them in another text editor and fix the package lines. When you now open eclipse, do a refresh and full rebuild. Things should be fine then.

记住:你总是可以进入日食以外的地方工作。关闭它,打开文件资源管理器并创建使用您要使用的名称的目录。然后手动将文件移动到其目标目录。如果您愿意,可以在另一个文本编辑器中打开它们并修复包行。当你现在打开eclipse时,进行刷新和完全重建。事情应该没问题。

That is probably not the most elegant solution, but it always works. And more importantly, you are in full control of everything that happens!

这可能不是最优雅的解决方案,但它始终有效。更重要的是,您可以完全控制所发生的一切!

And for the record: the real answer to avoid catastrophic loss of code is to use a source code management system such as git. And to then push your changes constantly out to that "backup" facility.

并且为了记录:避免灾难性代码丢失的真正答案是使用源代码管理系统,如git。然后将您的更改不断推送到“备份”工具。